Mercurial Hosting > traffic-intelligence
diff python/sumo.py @ 998:933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Sun, 27 May 2018 23:22:48 -0400 |
parents | 32a34a143c27 |
children |
line wrap: on
line diff
--- a/python/sumo.py Fri May 25 18:15:18 2018 -0400 +++ b/python/sumo.py Sun May 27 23:22:48 2018 -0400 @@ -16,7 +16,7 @@ f.readline() # skip the headers for r in f: tmp = r.strip().split(',') - tazID = tmp[1] + tazID = tmp[1] for edge in tmp[2:]: if len(edge) > 0: if tazID in tazs: @@ -29,7 +29,7 @@ def edge2Taz(tazs): '''Returns the associative array of the TAZ of each SUMO edge''' edge2Tazs = {} - for taz, edges in tazs.iteritems(): + for taz, edges in tazs.items(): for edge in edges: if edge in edge2Tazs: print('error for edge: {} (taz {}/{})'.format(edge, edge2Tazs[edge], taz)) @@ -38,11 +38,11 @@ def saveTazEdges(outFilename, tazs): with open(outFilename,'w') as out: - out.write('<tazs>\n') - for tazID in tazs: - out.write('<taz id="{}" edges="'.format(tazID)+' '.join(tazs[tazID])+'"/>\n') - out.write('</tazs>\n') - + out.write('<tazs>\n') + for tazID in tazs: + out.write('<taz id="{}" edges="'.format(tazID)+' '.join(tazs[tazID])+'"/>\n') + out.write('</tazs>\n') + # TODO add utils from process-cyber.py? # if __name__ == "__main__":