Skip to content

Commit

Permalink
use exist_ok
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAFile committed Mar 22, 2018
1 parent 52663d7 commit 57272a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
6 changes: 2 additions & 4 deletions piqueserver/run.py
Expand Up @@ -40,8 +40,7 @@ def copytree(src, dst):
Doesn't over-write if src/dst files don't differ.
Creates a backup of dst file before over-writing.
"""
if not os.path.exists(dst):
os.makedirs(dst)
os.makedirs(dst, exist_ok=True)
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
Expand Down Expand Up @@ -84,8 +83,7 @@ def update_geoip(target_dir):
print('Configuration directory does not exist')
return 1

if not os.path.exists(working_directory):
os.makedirs(working_directory)
os.makedirs(working_directory, exist_ok=True)

print('Downloading %s' % MAXMIND_DOWNLOAD)

Expand Down
5 changes: 1 addition & 4 deletions piqueserver/server.py
Expand Up @@ -166,10 +166,7 @@ def check_scripts(scripts):

def ensure_dir_exists(filename: str) -> None:
d = os.path.dirname(filename)
try:
os.makedirs(d)
except FileExistsError:
pass
os.makedirs(d, exist_ok=True)


def random_choice_cycle(choices):
Expand Down

0 comments on commit 57272a8

Please sign in to comment.