diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-03-04 21:26:42 -0500 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-03-04 21:26:42 -0500 |
commit | a76fa564e461c310360575c74dc8bfba3d1bda74 (patch) | |
tree | c5250683dfdada2760de614142f32d188d4ffc1a /combox/file.py | |
parent | 8b4c2404270ee4d3db33e9dd4d7c0590dafd7411 (diff) |
renamed combox.file.rm_dir -> combox.file.rm_path
rm_path deletes a file or an empty directory.
updated the test for it too.
modified: tests/file_test.py
Diffstat (limited to 'combox/file.py')
-rw-r--r-- | combox/file.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/combox/file.py b/combox/file.py index 461d313..1e680c6 100644 --- a/combox/file.py +++ b/combox/file.py @@ -128,13 +128,19 @@ def rm_nodedir(directory, config): for node in nodes: dir_path = path.join(node, rel_path) - rm_dir(dir_path) + rm_path(dir_path) -def rm_dir(directory): - """Removes directory""" +def rm_path(fpath): + """Removes fpath. + + fpath can be a file or a empty directory. + """ try: - os.rmdir(directory) + if path.isfile(fpath): + os.remove(fpath) + else: + os.rmdir(fpath) except OSError, e: print e, "Something wrong. report bug to sravik@bgsu.edu" |