Skip to content

Commit ab73278

Browse files
committed
Using plain, non-namespaced xml methods methods for clarity
1 parent d36702f commit ab73278

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

bin/convert_logs.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ def __init__(self, filename, date, author):
2424
self.filename = filename
2525
self.date = date
2626
self.author = author
27+
28+
def properties(self):
29+
"""returns a dict of properties and their names for XML serialization"""
30+
return {
31+
"date": str(self.date),
32+
"filename": self.filename,
33+
"author": self.author
34+
}
2735

2836
# Some version control system's logs are not in chronological order, so
2937
# this compare method will return a compare of the date attributes.
@@ -111,27 +119,21 @@ def main(argv):
111119
def create_event_xml(events, output):
112120
""" Write out the final XML given an input iterator of events."""
113121
from xml.sax.saxutils import XMLGenerator
114-
from xml.sax.xmlreader import AttributesNSImpl
115122

116123
generator = XMLGenerator(output, "utf-8")
117-
generator.startDocument()
118-
119-
generator.startElementNS((None, 'file_events'), 'file_events', AttributesNSImpl({},{}))
124+
generator.startDocument()
125+
generator.startElement('file_events', {})
120126

121127
qnames = {(None, "date"):"date",
122128
(None, "filename"):"filename",
123129
(None, "author"):"author"}
124130

125131
for event in events:
126-
generator.startElementNS((None, "event"), "event", AttributesNSImpl({
127-
(None,"date"):str(event.date),
128-
(None,"filename"):event.filename,
129-
(None,"author"):event.author
130-
}, qnames))
132+
generator.startElement("event", event.properties())
131133

132-
generator.endElementNS((None, "event"), "event")
134+
generator.endElement("event")
133135

134-
generator.endElementNS((None, 'file_events'), 'file_events')
136+
generator.endElement('file_events')
135137
generator.endDocument()
136138

137139
def parse_args(argv):

0 commit comments

Comments
 (0)