Mercurial Hosting > traffic-intelligence
comparison python/utils.py @ 46:b5d007612e16
added filename util
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 06 Aug 2010 19:45:47 -0400 |
parents | 74d2de078baf |
children | 8aed225f71d8 |
comparison
equal
deleted
inserted
replaced
45:74d2de078baf | 46:b5d007612e16 |
---|---|
159 if i>0: | 159 if i>0: |
160 return filename[:i] | 160 return filename[:i] |
161 else: | 161 else: |
162 return filename | 162 return filename |
163 | 163 |
164 def cleanFilename(s): | |
165 'cleans filenames obtained when contatenating figure characteristics' | |
166 return s.replace(' ','-').replace('.','') | |
167 | |
164 def listfiles(dirname, extension, remove = False): | 168 def listfiles(dirname, extension, remove = False): |
165 '''Returns the list of files with the extension in the directory dirname | 169 '''Returns the list of files with the extension in the directory dirname |
166 If remove is True, the filenames are stripped from the extension''' | 170 If remove is True, the filenames are stripped from the extension''' |
167 from os import listdir | 171 from os import listdir |
168 tmp = [f for f in listdir(dirname) if f.endswith(extension)] | 172 tmp = [f for f in listdir(dirname) if f.endswith(extension)] |