diff options
author | 2017-08-14 00:13:41 +0200 | |
---|---|---|
committer | 2017-08-14 00:14:59 +0200 | |
commit | 9ab6d637e57caba3be41c3379d50b96184afd5e5 (patch) | |
tree | 6d9645b758efe0c4378e6cc19c73238c9808ab40 | |
parent | assign a default value to these args (diff) | |
download | javatoolkit-9ab6d637e57caba3be41c3379d50b96184afd5e5.tar.gz javatoolkit-9ab6d637e57caba3be41c3379d50b96184afd5e5.tar.bz2 javatoolkit-9ab6d637e57caba3be41c3379d50b96184afd5e5.zip |
rework SaxRewriterBase and SaxRewriter classes
-rwxr-xr-x | src/py/xml-rewrite-2.py | 22 |
1 files 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, |