diff options
author | Ori Bernstein <ori@eigenstate.org> | 2021-06-14 00:00:37 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-06-14 00:00:37 +0000 |
commit | a73a964e51247ed169d322c725a3a18859f109a3 (patch) | |
tree | 3f752d117274d444bda44e85609aeac1acf313f3 /sys/src/cmd/python/Demo/xml/elem_count.py | |
parent | e64efe273fcb921a61bf27d33b230c4e64fcd425 (diff) |
python, hg: tow outside the environment.
they've served us well, and can ride off into the sunset.
Diffstat (limited to 'sys/src/cmd/python/Demo/xml/elem_count.py')
-rw-r--r-- | sys/src/cmd/python/Demo/xml/elem_count.py | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/sys/src/cmd/python/Demo/xml/elem_count.py b/sys/src/cmd/python/Demo/xml/elem_count.py deleted file mode 100644 index 7b53189c7..000000000 --- a/sys/src/cmd/python/Demo/xml/elem_count.py +++ /dev/null @@ -1,36 +0,0 @@ -import sys - -from xml.sax import make_parser, handler - -class FancyCounter(handler.ContentHandler): - - def __init__(self): - self._elems = 0 - self._attrs = 0 - self._elem_types = {} - self._attr_types = {} - - def startElement(self, name, attrs): - self._elems = self._elems + 1 - self._attrs = self._attrs + len(attrs) - self._elem_types[name] = self._elem_types.get(name, 0) + 1 - - for name in attrs.keys(): - self._attr_types[name] = self._attr_types.get(name, 0) + 1 - - def endDocument(self): - print "There were", self._elems, "elements." - print "There were", self._attrs, "attributes." - - print "---ELEMENT TYPES" - for pair in self._elem_types.items(): - print "%20s %d" % pair - - print "---ATTRIBUTE TYPES" - for pair in self._attr_types.items(): - print "%20s %d" % pair - - -parser = make_parser() -parser.setContentHandler(FancyCounter()) -parser.parse(sys.argv[1]) |