commit: 9ab6d637e57caba3be41c3379d50b96184afd5e5
Author: Patrice Clement <monsieurp <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 13 22:13:41 2017 +0000
Commit: Patrice Clement <monsieurp <AT> gentoo <DOT> org>
CommitDate: Sun Aug 13 22:14:59 2017 +0000
URL: https://gitweb.gentoo.org/proj/javatoolkit.git/commit/?id=9ab6d637
rework SaxRewriterBase and SaxRewriter classes
src/py/xml-rewrite-2.py | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/py/xml-rewrite-2.py b/src/py/xml-rewrite-2.py
index 1135cc3..c56de1d 100755
--- a/src/py/xml-rewrite-2.py
+++ b/src/py/xml-rewrite-2.py
@@ -79,7 +79,7 @@ class DomRewriter:
class StreamRewriterBase:
- def __init__(self, elems=[], attributes=[], values=[], index,
+ def __init__(self, elems, attributes, values, index,
sourceElems=[], sourceAttributes=[], sourceValues=[],
targetElems=[], targetAttributes=[], targetValues=[]):
self.buffer = io.StringIO()
@@ -170,6 +170,20 @@ class SaxRewriter(XMLGenerator, StreamRewriterBase):
def __init__(self, elems, attributes, values, index,
sourceElems=[], sourceAttributes=[], sourceValues=[],
targetElems=[], targetAttributes=[], targetValues=[]):
+ if not sourceElems:
+ sourceElems = []
+ if not sourceAttributes:
+ sourceAttributes = []
+ if not sourceValues:
+ sourceValues = []
+ if not targetElems:
+ targetElems = []
+ if not targetAttributes:
+ targetAttributes = []
+ if not targetValues:
+ targetValues = []
+ if not index:
+ index = 0
StreamRewriterBase.__init__(self, elems, attributes, values, index,
sourceElems, sourceAttributes,
sourceValues,
targetElems, targetAttributes,
targetValues)
@@ -327,9 +341,9 @@ parameters will break the script."""
def get_rewriter(options):
if options.index or options.doDelete or options.gentoo_classpath:
- # java-ant-2.eclass does not use these options so we can
optimize the ExpatWriter
- # and let the DomRewriter do these. Also keeps the index option
- # compatible for sure.
+ # java-ant-2.eclass does not use these options so we can optimize
the ExpatWriter
+ # and let the DomRewriter do these. Also keeps the index option
+ # compatible for sure.
rewriter = DomRewriter(
options.elements,
options.attributes,