/usr/share/sumo/tools/game/patchTrafficLights.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 49 50 51 | #!/usr/bin/env python
"""
@file patchTrafficLights.py
@author Michael Behrisch
@author Jakob Erdmann
@date 2010-03-11
@version $Id: patchTrafficLights.py 11671 2012-01-07 20:14:30Z behrisch $
This script patches the traffic lights of an input network for the gaming mode.
SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
Copyright (C) 2010-2012 DLR (http://www.dlr.de/) and contributors
All rights reserved
"""
import re, sys
from optparse import OptionParser
optParser = OptionParser()
optParser.add_option("-n", "--net-file", dest="netfile",
help="define the input net file (mandatory)")
optParser.add_option("-o", "--output-net-file", dest="outfile",
default="out.net.xml", help="define the output net filename")
optParser.add_option("-s", "--switch", type="int", default=2, help="switch time")
(options, args) = optParser.parse_args()
if not options.netfile:
optParser.print_help()
sys.exit()
skip = False
tlid = ""
out = open(options.outfile, "w")
for line in open(options.netfile):
if tlid and not skip:
m = re.search('state="([^"]+)"', line)
if m and len(m.group(1)) == 16:
skip = True
print >> out, """ <phase duration="%s" state="rrrrrrrrrrrrrrrr"/>
<phase duration="10000" state="rrrrGGggrrrrGGgg"/>
</tlLogic>
<tlLogic id="%s" type="static" programID="1" offset="0">
<phase duration="%s" state="rrrrrrrrrrrrrrrr"/>
<phase duration="10000" state="GGggrrrrGGggrrrr"/>""" % (options.switch, tlid, options.switch)
m = re.search('<tlLogic id="([^"]+)"', line)
if m:
tlid = m.group(1)
if re.search('</tlLogic>', line):
skip = False
tlid = ""
if not skip:
out.write(line)
|