Mercurial Hosting > traffic-intelligence
diff python/utils.py @ 266:aba9711b3149
small modificatons and reorganization
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 27 Jul 2012 10:29:24 -0400 |
parents | a048066bd20f |
children | 78922b4de3bf |
line wrap: on
line diff
--- a/python/utils.py Thu Jul 26 19:46:36 2012 -0400 +++ b/python/utils.py Fri Jul 27 10:29:24 2012 -0400 @@ -300,7 +300,7 @@ def cleanFilename(s): 'cleans filenames obtained when contatenating figure characteristics' - return s.replace(' ','-').replace('.','') + return s.replace(' ','-').replace('.','').replace('/','-') def listfiles(dirname, extension, remove = False): '''Returns the list of files with the extension in the directory dirname @@ -313,11 +313,22 @@ else: return tmp +def mkdir(dirname): + 'Creates a directory if it does not exist' + import os + if not os.path.exists(dirname): + os.mkdir(dirname) + else: + print(dirname+' already exists') + def removeFile(filename): '''Deletes the file while avoiding raising an error if the file does not exist''' + import os if (os.path.exists(filename)): os.remove(filename) + else: + print(filename+' does not exist') def plotPolygon(poly, options = ''): from numpy.core.multiarray import array