* don't reinvent the wheel
This commit is contained in:
+8
-8
@@ -19,16 +19,16 @@ def check_file(file, mode = os.F_OK):
|
|||||||
# FIXME: could have a better name
|
# FIXME: could have a better name
|
||||||
def check_dir(dir):
|
def check_dir(dir):
|
||||||
dir = dir.strip().rstrip("/")
|
dir = dir.strip().rstrip("/")
|
||||||
#print 'check dir ', dir
|
|
||||||
if not os.access(dir, os.F_OK):
|
if not os.access(dir, os.F_OK):
|
||||||
|
os.makedirs(dir)
|
||||||
# does the parent exist?
|
# does the parent exist?
|
||||||
(parent_dir, curr_dir) = os.path.split(dir)
|
## (parent_dir, curr_dir) = os.path.split(dir)
|
||||||
if parent_dir != "/":
|
## if parent_dir != "/":
|
||||||
check_dir(parent_dir)
|
## check_dir(parent_dir)
|
||||||
try:
|
## try:
|
||||||
os.mkdir(dir)
|
## os.mkdir(dir)
|
||||||
except OSError, e:
|
## except OSError, e:
|
||||||
raise UtilError("%s" % e)
|
## raise UtilError("%s" % e)
|
||||||
|
|
||||||
def purge_dir(top):
|
def purge_dir(top):
|
||||||
"""Remove all content of a directory (top)"""
|
"""Remove all content of a directory (top)"""
|
||||||
|
|||||||
Reference in New Issue
Block a user