1 |
commit: 9ab6d637e57caba3be41c3379d50b96184afd5e5 |
2 |
Author: Patrice Clement <monsieurp <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Aug 13 22:13:41 2017 +0000 |
4 |
Commit: Patrice Clement <monsieurp <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 13 22:14:59 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/javatoolkit.git/commit/?id=9ab6d637 |
7 |
|
8 |
rework SaxRewriterBase and SaxRewriter classes |
9 |
|
10 |
src/py/xml-rewrite-2.py | 22 ++++++++++++++++++---- |
11 |
1 file changed, 18 insertions(+), 4 deletions(-) |
12 |
|
13 |
diff --git a/src/py/xml-rewrite-2.py b/src/py/xml-rewrite-2.py |
14 |
index 1135cc3..c56de1d 100755 |
15 |
--- a/src/py/xml-rewrite-2.py |
16 |
+++ b/src/py/xml-rewrite-2.py |
17 |
@@ -79,7 +79,7 @@ class DomRewriter: |
18 |
|
19 |
|
20 |
class StreamRewriterBase: |
21 |
- def __init__(self, elems=[], attributes=[], values=[], index, |
22 |
+ def __init__(self, elems, attributes, values, index, |
23 |
sourceElems=[], sourceAttributes=[], sourceValues=[], |
24 |
targetElems=[], targetAttributes=[], targetValues=[]): |
25 |
self.buffer = io.StringIO() |
26 |
@@ -170,6 +170,20 @@ class SaxRewriter(XMLGenerator, StreamRewriterBase): |
27 |
def __init__(self, elems, attributes, values, index, |
28 |
sourceElems=[], sourceAttributes=[], sourceValues=[], |
29 |
targetElems=[], targetAttributes=[], targetValues=[]): |
30 |
+ if not sourceElems: |
31 |
+ sourceElems = [] |
32 |
+ if not sourceAttributes: |
33 |
+ sourceAttributes = [] |
34 |
+ if not sourceValues: |
35 |
+ sourceValues = [] |
36 |
+ if not targetElems: |
37 |
+ targetElems = [] |
38 |
+ if not targetAttributes: |
39 |
+ targetAttributes = [] |
40 |
+ if not targetValues: |
41 |
+ targetValues = [] |
42 |
+ if not index: |
43 |
+ index = 0 |
44 |
StreamRewriterBase.__init__(self, elems, attributes, values, index, |
45 |
sourceElems, sourceAttributes, sourceValues, |
46 |
targetElems, targetAttributes, targetValues) |
47 |
@@ -327,9 +341,9 @@ parameters will break the script.""" |
48 |
|
49 |
def get_rewriter(options): |
50 |
if options.index or options.doDelete or options.gentoo_classpath: |
51 |
- # java-ant-2.eclass does not use these options so we can optimize the ExpatWriter |
52 |
- # and let the DomRewriter do these. Also keeps the index option |
53 |
- # compatible for sure. |
54 |
+ # java-ant-2.eclass does not use these options so we can optimize the ExpatWriter |
55 |
+ # and let the DomRewriter do these. Also keeps the index option |
56 |
+ # compatible for sure. |
57 |
rewriter = DomRewriter( |
58 |
options.elements, |
59 |
options.attributes, |