comparison makeitso/python_package/{{package}}/{{main}}.py @ 205:0a991b8fe839

better check
author Jeff Hammel <k0scist@gmail.com>
date Fri, 21 Nov 2014 12:19:07 -0800
parents be7e2e336d7a
children d9d7bfdb54db
comparison
equal deleted inserted replaced
204:388b4bb3516c 205:0a991b8fe839
17 string = (str, unicode) 17 string = (str, unicode)
18 18
19 def ensure_dir(directory): 19 def ensure_dir(directory):
20 """ensure a directory exists""" 20 """ensure a directory exists"""
21 if os.path.exists(directory): 21 if os.path.exists(directory):
22 assert os.path.isdir(directory) 22 if not os.path.isdir(directory):
23 raise OSError("Not a directory: '{}'".format(directory))
23 return directory 24 return directory
24 os.makedirs(directory) 25 os.makedirs(directory)
25 return directory 26 return directory
26 27
27 28