Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
writeHeader(busStops, os.path.basename(__file__), 'additional')
if options.additional_input:
num_busstops = 0
kept_busstops = 0
num_taz = 0
kept_taz = 0
for busStop in parse(options.additional_input, ('busStop', 'trainStop')):
num_busstops += 1
edge = busStop.lane[:-2]
busStopEdges[busStop.id] = edge
if options.stops_output and edge in edges:
kept_busstops += 1
if busStop.access:
busStop.access = [acc for acc in busStop.access if acc.lane[:-2] in edges]
busStops.write(busStop.toXML(' '))
for taz in parse(options.additional_input, 'taz'):
num_taz += 1
taz_edges = [e for e in taz.edges.split() if e in edges]
if taz_edges:
taz.edges = " ".join(taz_edges)
if options.stops_output:
kept_taz += 1
busStops.write(taz.toXML(' '))
if num_busstops > 0 and num_taz > 0:
print("Kept %s of %s busStops and %s of %s tazs" % (
kept_busstops, num_busstops, kept_taz, num_taz))
elif num_busstops > 0:
print("Kept %s of %s busStops" % (
kept_busstops, num_busstops))
elif num_taz > 0:
print("Kept %s of %s tazs" % (
kept_taz, num_taz))
if options.trips:
writer = write_trip
else:
writer = write_route
busStopEdges = {}
if options.stops_output:
busStops = open(options.stops_output, 'w')
writeHeader(busStops, os.path.basename(__file__), 'additional')
if options.additional_input:
num_busstops = 0
kept_busstops = 0
num_taz = 0
kept_taz = 0
for busStop in parse(options.additional_input, ('busStop', 'trainStop')):
num_busstops += 1
edge = busStop.lane[:-2]
busStopEdges[busStop.id] = edge
if options.stops_output and edge in edges:
kept_busstops += 1
if busStop.access:
busStop.access = [acc for acc in busStop.access if acc.lane[:-2] in edges]
busStops.write(busStop.toXML(' '))
for taz in parse(options.additional_input, 'taz'):
num_taz += 1
taz_edges = [e for e in taz.edges.split() if e in edges]
if taz_edges:
taz.edges = " ".join(taz_edges)
if options.stops_output:
kept_taz += 1
busStops.write(taz.toXML(' '))
def main(options):
counts = defaultdict(lambda: list())
for routeFile in options.routeFiles.split(','):
for person in sumolib.xml.parse(routeFile, 'person'):
stages = tuple([stageName(options, person, s) for s in person.getChildList()])
if options.mergeWalks:
filtered = []
for s in stages:
if len(filtered) == 0 or s != filtered[-1]:
filtered.append(s)
stages = tuple(filtered)
counts[stages].append(person.id)
numPersons = sum(map(len, counts.values()))
print("Loaded %s persons" % numPersons)
maxPadding = max(map(len, [' '.join(k) for k, v in counts.items()]))
countSize = len(str(max([len(p) for k, p in counts.items()])))
formatStr = "%" + str(countSize) + "s: %s%s"
reverseCounts = [(len(p), k) for k, p in counts.items()]
for count, k in sorted(reverseCounts):
def readPOI(traceFile, net):
trace = []
for poi in sumolib.xml.parse(traceFile, "poi"):
if poi.lon is None:
trace.append((poi.x, poi.y))
else:
trace.append(net.convertLonLat2XY(poi.lon, poi.lat))
yield "blub", trace
def readDetectors(self, detFile):
self._detReader = detector.DetectorReader(detFile, self._lane2edge)
for edge, detGroups in self._detReader._edge2DetData.items():
for group in detGroups:
if group.isValid:
self._net.getEdge(edge).detGroup.append(group)
sources = set()
sinks = set()
for det in sumolib.xml.parse(detFile, ["detectorDefinition", "e1Detector"]):
if hasattr(det, "type"):
if det.type == "source":
if options.lanebased:
sources.add(det.lane)
else:
sources.add(det.lane[:det.lane.rfind("_")])
if det.type == "sink":
if options.lanebased:
sinks.add(det.lane)
else:
sinks.add(det.lane[:det.lane.rfind("_")])
return sources, sinks
def main(options):
if options.output is None:
options.outfile = sys.stdout
else:
options.outfile = open(options.output, 'w')
if options.flowout:
with open(options.flowout, 'w') as f:
f.write("Detector;Time;qPKW;vPKW\n")
options.begin = None
for interval in parse(options.edgeDataFile, "interval", attr_conversions={"begin": float, "end": float}):
if options.begin is None:
options.begin = interval.begin / 60
options.end = interval.end / 60
detReader = detector.DetectorReader(options.detfile, LaneMap())
intervalBeginM = options.begin
haveDetFlows = True
while ((options.end is None and haveDetFlows) or
(options.end is not None and intervalBeginM < options.end)):
intervalEndM = intervalBeginM + options.interval
if options.end is not None:
intervalEndM = min(intervalEndM, options.end)
if options.flowfile:
if options.verbose:
print("Reading flows")
haveDetFlows = detReader.readFlows(options.flowfile, flow=options.flowcol,
def from_stream(input_connections):
""" Constructs Connections object from connections defined in the given
stream. The input_connections argument may be a filename or an opened
file. """
LOGGER.info("Reading connections from input stream")
connections = Connections()
for xml_connection in sumolib.xml.parse(input_connections, "connection"):
connections.add(xml_connection.attr_from,
xml_connection.fromLane,
xml_connection.to)
return connections