/usr/share/sumo/tools/10to11.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 52 53 54 55 56 57 58 59 60 61 62 | #!/usr/bin/env python
"""
@file 10to11.py
@author Michael Behrisch
@date 2009-06-09
@version $Id: 10to11.py 11671 2012-01-07 20:14:30Z behrisch $
Transfers configuration files from character data to attribute style.
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 os, sys, re
from xml.sax import make_parser, handler
from optparse import OptionParser
class ConfigReader(handler.ContentHandler):
def __init__(self):
self._parent = None
self._parentWritten = ""
self._element = None
self._string = ''
def startElement(self, name, attrs):
self._parent = self._element
self._element = name
self._string = ''
def characters(self, content):
self._string += content
def endElement(self, name):
if self._parent == name:
print ' </%s>' % name
self._parentWritten = ""
elif self._element == name:
if not self._parentWritten:
print ' <%s>' % self._parent
self._parentWritten = self._parent
print ' <%s value="%s"/>' % (self._element, self._string)
self._element = self._parent
def startDocument(self):
print '<configuration>'
def endDocument(self):
if self._parentWritten:
print ' </%s>' % self._parentWritten
print '</configuration>'
optParser = OptionParser(usage="usage: %prog <config>+")
(options, args) = optParser.parse_args()
if len(args) == 0:
optParser.print_help()
sys.exit()
for f in args:
parser = make_parser()
parser.setContentHandler(ConfigReader())
parser.parse(f)
|