E5XML/XMLHandlerBase.py

Fri, 10 Sep 2010 08:54:33 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 10 Sep 2010 08:54:33 +0200
changeset 580
45c38566b001
parent 110
c9a969db1469
child 792
a13346916170
permissions
-rw-r--r--

Implemented the plug-in repository reader.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
13
1af94a91f439 Changed copyright for 2010.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 12
diff changeset
3 # Copyright (c) 2004 - 2010 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
7 Module implementing a base class for all of eric5s XML handlers.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
45
9a18f4dbb493 Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
10 import pickle
9a18f4dbb493 Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
11 import base64
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from xml.sax.handler import ContentHandler
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 class XMLHandlerBase(ContentHandler):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 """
15
f6ccc31d6e72 Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
17 Class implementing the base class for al of eric5s XML handlers.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 def __init__(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 self.startDocumentSpecific = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 self.elements = {
44
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
26 'none' : (self.defaultStartElement, self.endNone),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
27 'int' : (self.defaultStartElement, self.endInt),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
28 'float' : (self.defaultStartElement, self.endFloat),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
29 'complex' : (self.defaultStartElement, self.endComplex),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
30 'bool' : (self.defaultStartElement, self.endBool),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
31 'string' : (self.defaultStartElement, self.endString),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
32 'bytes' : (self.defaultStartElement, self.endBytes),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
33 'bytearray' : (self.defaultStartElement, self.endBytearray),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
34 'tuple' : (self.startTuple, self.endTuple),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
35 'list' : (self.startList, self.endList),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
36 'dict' : (self.startDictionary, self.endDictionary),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
37 'set' : (self.startSet, self.endSet),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
38 'frozenset' : (self.startFrozenset, self.endFrozenset),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
39 'pickle' : (self.startPickle, self.endPickle),
42
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
40 # for backward compatibility
44
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
41 'long' : (self.defaultStartElement, self.endInt),
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
42 'unicode' : (self.defaultStartElement, self.endString),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 }
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.buffer = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self._marker = '__MARKER__'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
49 self.NEWPARA = chr(0x2029)
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
50 self.NEWLINE = chr(0x2028)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 def unescape(self, text, attribute = False):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 Public method used to unescape certain characters.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @param text the text to unescape (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @param attribute flag indicating unescaping is done for an attribute
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 if attribute:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 return text.replace("&quot;",'"').replace("&gt;",">")\
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 .replace("&lt;","<").replace("&amp;","&")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 return text.replace("&gt;",">").replace("&lt;","<").replace("&amp;","&")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 def decodedNewLines(self, text):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Public method to decode newlines and paragraph breaks.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
110
c9a969db1469 Fixed doc string still containing QString and QStringList.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 96
diff changeset
69 @param text text to decode (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 return text.replace(self.NEWPARA, "\n\n").replace(self.NEWLINE, "\n")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 def startDocument(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 Handler called, when the document parsing is started.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.buffer = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 if self.startDocumentSpecific is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.startDocumentSpecific()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 def startElement(self, name, attrs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 Handler called, when a starting tag is found.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 @param name name of the tag (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 @param attrs list of tag attributes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.elements[name][0](attrs)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 def endElement(self, name):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 Handler called, when an ending tag is found.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 @param name name of the tag (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.elements[name][1]()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def characters(self, chars):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 Handler called for ordinary text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @param chars the scanned text (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 self.buffer += chars
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 def defaultStartElement(self, attrs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 Handler method for common start tags.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @param attrs list of tag attributes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 self.buffer = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 def defaultEndElement(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 Handler method for the common end tags.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 pass
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 def _prepareBasics(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 Protected method to prepare the parsing of XML for basic python types.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.stack = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 ## The various handler methods for basic types
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 ############################################################################
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 def endNone(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 Handler method for the "none" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.stack.append(None)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def endInt(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Handler method for the "int" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 self.stack.append(int(self.buffer.strip()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 def endBool(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 Handler method for the "bool" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 if self.buffer.strip() == "True":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.stack.append(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 self.stack.append(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 def endFloat(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 Handler method for the "float" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 self.stack.append(float(self.buffer.strip()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 def endComplex(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 Handler method for the "complex" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 real, imag = self.buffer.strip().split()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 self.stack.append(float(real) + float(imag)*1j)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 def endString(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 Handler method for the "string" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 """
45
9a18f4dbb493 Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
174 s = str(self.unescape(self.buffer))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.stack.append(s)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
44
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
177 def endBytes(self):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
178 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
179 Handler method for the "bytes" end tag.
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
180 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
181 by = bytes([int(b) for b in self.buffer.strip().split(",")])
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
182 self.stack.append(by)
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
183
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
184 def endBytearray(self):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
185 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
186 Handler method for the "bytearray" end tag.
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
187 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
188 by = bytearray([int(b) for b in self.buffer.strip().split(",")])
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
189 self.stack.append(by)
45
9a18f4dbb493 Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
190
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 def startList(self, attrs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 Handler method for the "list" start tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 @param attrs list of tag attributes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.stack.append(self._marker)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 def endList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 Handler method for the "list" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 for i in range(len(self.stack) - 1, -1, -1):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 if self.stack[i] is self._marker:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 assert i != -1
44
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
207 l = self.stack[i + 1:len(self.stack)]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.stack[i:] = [l]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def startTuple(self, attrs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Handler method for the "tuple" start tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 @param attrs list of tag attributes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.stack.append(self._marker)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 def endTuple(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 Handler method for the "tuple" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 for i in range(len(self.stack) - 1, -1, -1):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 if self.stack[i] is self._marker:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 assert i != -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 t = tuple(self.stack[i + 1:len(self.stack)])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.stack[i:] = [t]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 def startDictionary(self, attrs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 Handler method for the "dictionary" start tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 @param attrs list of tag attributes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 self.stack.append(self._marker)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 def endDictionary(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 Handler method for the "dictionary" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 for i in range(len(self.stack) - 1, -1, -1):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 if self.stack[i] is self._marker:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 break
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 assert i != -1
44
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
245 d = {}
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
246 for j in range(i + 1, len(self.stack), 2):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 d[self.stack[j]] = self.stack[j + 1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 self.stack[i:] = [d]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249
44
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
250 def startSet(self, attrs):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
251 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
252 Handler method for the "set" start tag.
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
253
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
254 @param attrs list of tag attributes
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
255 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
256 self.stack.append(self._marker)
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
257
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
258 def endSet(self):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
259 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
260 Handler method for the "set" end tag.
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
261 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
262 for i in range(len(self.stack) - 1, -1, -1):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
263 if self.stack[i] is self._marker:
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
264 break
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
265 assert i != -1
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
266 s = set(self.stack[i + 1:len(self.stack)])
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
267 self.stack[i:] = [s]
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
268
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
269 def startFrozenset(self, attrs):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
270 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
271 Handler method for the "frozenset" start tag.
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
272
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
273 @param attrs list of tag attributes
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
274 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
275 self.stack.append(self._marker)
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
276
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
277 def endFrozenset(self):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
278 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
279 Handler method for the "frozenset" end tag.
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
280 """
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
281 for i in range(len(self.stack) - 1, -1, -1):
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
282 if self.stack[i] is self._marker:
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
283 break
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
284 assert i != -1
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
285 f = frozenset(self.stack[i + 1:len(self.stack)])
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
286 self.stack[i:] = [f]
fe5cd20cb0eb Added new Python3 types to XMLWriterBase and XMLHandlerBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 42
diff changeset
287
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 def startPickle(self, attrs):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 Handler method for the "pickle" start tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 @param attrs list of tag attributes
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 self.pickleEnc = attrs.get("encoding", "base64")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 def endPickle(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 Handler method for the "pickle" end tag.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 """
45
9a18f4dbb493 Did a lot of encoding related stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 44
diff changeset
300 pic = base64.b64decode(self.buffer.encode("ASCII"))
42
23b45a742e17 Fixed a bunch of issues including a workaround for a bug in the Python email package (s. EmailDialog.py).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
301 self.stack.append(pickle.loads(pic))

eric ide

mercurial