Mercurial Hosting > traffic-intelligence
diff python/utils.py @ 304:20f9cd972dde
added capability to parse cfg file for display-trajectories.py
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 29 Mar 2013 16:56:23 -0400 |
parents | 27f06d28036d |
children | 6c068047edbf |
line wrap: on
line diff
--- a/python/utils.py Thu Mar 21 14:01:46 2013 -0400 +++ b/python/utils.py Fri Mar 29 16:56:23 2013 -0400 @@ -330,6 +330,22 @@ s = readline(f) return dataStrings +class FakeSecHead(object): + '''Add fake section header [asection] + + from http://stackoverflow.com/questions/2819696/parsing-properties-file-in-python/2819788#2819788 + use read_file in Python 3.2+ + ''' + def __init__(self, fp): + self.fp = fp + self.sechead = '[main]\n' + + def readline(self): + if self.sechead: + try: return self.sechead + finally: self.sechead = None + else: return self.fp.readline() + def removeExtension(filename, delimiter = '.'): '''Returns the filename minus the extension (all characters after last .)''' i = filename.rfind(delimiter)