/usr/share/sumo/tools/assign/addTaz.py is in sumo-tools 0.15.0~dfsg-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #!/usr/bin/env python
"""
@file addTaz.py
@author Michael Behrisch
@date 2009-05-20
@version $Id: addTaz.py 11671 2012-01-07 20:14:30Z behrisch $
SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
Copyright (C) 2009-2012 DLR (http://www.dlr.de/) and contributors
All rights reserved
"""
import sys
from xml.sax import make_parser, handler
from optparse import OptionParser
class RouteReader(handler.ContentHandler):
def __init__(self, out):
self._idToTaz = {}
self._out = out
def startElement(self, name, attrs):
if name == 'tripdef':
self._idToTaz[attrs['id']] = (attrs['fromtaz'], attrs['totaz'])
elif name != 'tripdefs':
print >> self._out, '<' + name,
for key in attrs.keys():
print >> self._out, '%s="%s"' % (key, attrs[key]),
if name == 'vehicle':
print >> self._out, 'fromtaz="%s" totaz="%s"' % self._idToTaz[attrs['id']],
print >> self._out, '>'
def endElement(self, name):
if name != 'tripdefs' and name != 'tripdef':
print >> self._out, '</%s>' % name
def parse(trips, routes, out):
parser = make_parser()
parser.setContentHandler(RouteReader(out))
parser.parse(trips)
parser.parse(routes)
if __name__ == "__main__":
optParser = OptionParser(usage="usage: %prog [options] <routefile>+")
optParser.add_option("-r", "--routes", help="routes file")
optParser.add_option("-t", "--trips", help="trips file")
(options, args) = optParser.parse_args()
parse(options.trips, options.routes, sys.stdout)
|