mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 09:58:31 +07:00
Fixed bug in clear_directory (fails if directory does not exist)
This commit is contained in:
@@ -37,15 +37,16 @@ def clear_directory(directory):
|
||||
"""
|
||||
Remove the content of a directory recursively but not the directory itself.
|
||||
"""
|
||||
for entry in os.listdir(directory):
|
||||
path = os.path.join(directory, entry)
|
||||
try:
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path, True)
|
||||
else:
|
||||
os.unlink(path)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if os.path.exists(directory):
|
||||
for entry in os.listdir(directory):
|
||||
path = os.path.join(directory, entry)
|
||||
try:
|
||||
if os.path.isdir(path):
|
||||
shutil.rmtree(path, True)
|
||||
else:
|
||||
os.unlink(path)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
def copy_media_files(from_dir, to_dir):
|
||||
|
||||
Reference in New Issue
Block a user