don't reimplement the wheel
This commit is contained in:
+8
-6
@@ -143,13 +143,15 @@ def check_dir(dir):
|
|||||||
if not os.access(dir, os.F_OK):
|
if not os.access(dir, os.F_OK):
|
||||||
os.makedirs(dir)
|
os.makedirs(dir)
|
||||||
|
|
||||||
def clean_dir(top):
|
def clean_dir(path):
|
||||||
"Remove all content of a directory (top)"
|
"Remove all content of a directory (top)"
|
||||||
for root, dirs, files in os.walk(top, topdown=False):
|
# for root, dirs, files in os.walk(top, topdown=False):
|
||||||
for name in files:
|
# for name in files:
|
||||||
os.remove(os.path.join(root, name))
|
# os.remove(os.path.join(root, name))
|
||||||
for name in dirs:
|
# for name in dirs:
|
||||||
os.rmdir(os.path.join(root, name))
|
# os.rmdir(os.path.join(root, name))
|
||||||
|
# don't reimplement the wheel
|
||||||
|
shutil.rmtree(path)
|
||||||
|
|
||||||
def dir_size(dir):
|
def dir_size(dir):
|
||||||
""" calculate the size of files under a dir
|
""" calculate the size of files under a dir
|
||||||
|
|||||||
Reference in New Issue
Block a user