This commit is contained in:
James Vasile 2011-12-16 23:42:29 -05:00 committed by James Vasile
parent bc8887e8b6
commit 02baab57a0

20
util.py
View File

@ -1,9 +1,27 @@
import sys
import os, sys
import cherrypy
import cfg
import sqlite3
from filedict import FileDict
def mkdir(newdir):
"""works the way a good mkdir should :)
- already exists, silently complete
- regular file in the way, raise an exception
- parent directory(ies) does not exist, make them as well
"""
if os.path.isdir(newdir):
pass
elif os.path.isfile(newdir):
raise OSError("a file with the same name as the desired " \
"dir, '%s', already exists." % newdir)
else:
head, tail = os.path.split(newdir)
if head and not os.path.isdir(head):
mkdir(head)
#print "mkdir %s" % repr(newdir)
if tail:
os.mkdir(newdir)
def is_string(obj):
isinstance(obj, basestring)
def is_ascii(s):