E5XML/XMLStreamReaderBase.py

Sat, 05 Jul 2014 11:41:14 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 11:41:14 +0200
changeset 3669
ac84ac3c0f05
parent 3656
441956d8fce5
child 3670
f0cb7579c0b4
permissions
-rw-r--r--

Continued renaming eric5 for PyQt5 to eric6.

574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3035
diff changeset
3 # Copyright (c) 2010 - 2014 Detlev Offenbach <detlev@die-offenbachs.de>
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a base class for all of eric5s XML stream writers.
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3060
diff changeset
10 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
11
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import pickle
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import base64
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
15 from PyQt5.QtCore import QXmlStreamReader, QCoreApplication
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
17 from E5Gui import E5MessageBox
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
18
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
19
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class XMLStreamReaderBase(QXmlStreamReader):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing a base class for all of eric5s XML stream readers.
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 def __init__(self, device):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Constructor
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param device reference to the I/O device to read from (QIODevice)
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
30 super(XMLStreamReaderBase, self).__init__(device)
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
592
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
32 def toBool(self, value):
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
33 """
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
34 Public method to convert the given value to bool.
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
35
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
36 @param value value to be converted ("True", "False", "1", "0")
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
37 @return converted value (boolean) or None in case of an error
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
38 """
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
39 if value.lower() in ["true", "false"]:
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
40 return value.lower() == "true"
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
41
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
42 if value in ["1", "0"]:
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
43 return bool(int(value))
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
44
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
45 self.raiseBadValue(value)
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
46 return None
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
47
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
48 def showErrorMessage(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
49 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
50 Public method to show an error message.
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
51 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
52 if self.hasError():
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
53 msg = QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
54 "XMLStreamReaderBase",
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
55 "<p>XML parse error in file <b>{0}</b>, line {1},"
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
56 " column {2}</p><p>Error: {3}</p>").format(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
57 self.device().fileName(),
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
58 self.lineNumber(), self.columnNumber(),
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
59 self.errorString())
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
60 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
61 None,
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
62 QCoreApplication.translate(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
63 "XMLStreamReaderBase", "XML parse error"),
589
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
64 msg)
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
65
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
66 def raiseUnexpectedStartTag(self, tag):
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
67 """
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
68 Public method to raise an error for an unexpected start tag.
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
69
589
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
70 @param tag name of the unexpected tag (string)
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
71 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
72 self.raiseError(QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
73 "XMLStreamReaderBase", "Unexpected start tag '{0}'.".format(tag)))
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
74
590
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
75 def raiseUnsupportedFormatVersion(self, version):
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
76 """
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
77 Public method to raise an error for an unsupported file format version.
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
78
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
79 @param version unsupported version (string)
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
80 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
81 self.raiseError(QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
82 "XMLStreamReaderBase",
604
a2671d497b49 Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 592
diff changeset
83 "File format version '{0}' is not supported.").format(version))
590
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
84
592
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
85 def raiseBadValue(self, value):
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
86 """
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
87 Public method to raise an error for a bad value.
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
88
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
89 @param value bad value (string)
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
90 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
91 self.raiseError(QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
92 "XMLStreamReaderBase", "Bad value: {0}").format(value))
592
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
93
578
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
94 def readXML(self):
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
95 """
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
96 Public method to read and parse the XML document.
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
97 """
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
98 pass
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
99
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
100 def attribute(self, name, default=""):
578
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
101 """
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
102 Public method to read the given attribute of the current tag.
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
103
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
104 @param name name of the attribute (string)
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
105 @param default default value (string)
2953
703452a2876f Started correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
106 @return value of the requested tag attribute (string)
578
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
107 """
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
108 att = self.attributes().value(name)
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
109 if att == "":
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
110 att = default
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
111 return att
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
112
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 def _skipUnknownElement(self):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 Protected method to skip over all unknown elements.
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 if not self.isStartElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 return
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 while not self.atEnd():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 self.readNext()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 if self.isEndElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 break
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 if self.isStartElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self._skipUnknownElement()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 def _readBasics(self):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 """
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
130 Protected method to read an object of a basic Python type.
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @return Python object read
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 while not self.atEnd():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.readNext()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if self.isStartElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 try:
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 if self.name() == "none":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
139 val = None
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 elif self.name() == "int":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
141 val = int(self.readElementText())
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
142 elif self.name() == "long":
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
143 # backward compatibility to 4.6
617
97baf3ff9d9d Added some compatibility code to XMLStreamReaderBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 605
diff changeset
144 val = int(self.readElementText())
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 elif self.name() == "bool":
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 b = self.readElementText()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 if b == "True":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
148 val = True
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 else:
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
150 val = False
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 elif self.name() == "float":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
152 val = float(self.readElementText())
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 elif self.name() == "complex":
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 real, imag = self.readElementText().split()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
155 val = float(real) + float(imag) * 1j
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 elif self.name() == "string":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
157 val = self.readElementText()
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
158 elif self.name() == "unicode":
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
159 # backward compatibility to 4.6
617
97baf3ff9d9d Added some compatibility code to XMLStreamReaderBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 605
diff changeset
160 val = self.readElementText()
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 elif self.name() == "bytes":
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
162 by = bytes([int(b) for b in
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
163 self.readElementText().split(",")])
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
164 val = by
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 elif self.name() == "bytearray":
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
166 by = bytearray([int(b) for b in
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
167 self.readElementText().split(",")])
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
168 val = by
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
169 elif self.name() == "tuple":
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
170 val = self.__readTuple()
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
171 return val
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
172 elif self.name() == "list":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
173 val = self.__readList()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
174 return val
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
175 elif self.name() == "dict":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
176 val = self.__readDict()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
177 return val
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
178 elif self.name() == "set":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
179 val = self.__readSet()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
180 return val
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
181 elif self.name() == "frozenset":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
182 val = self.__readFrozenset()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
183 return val
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
184 elif self.name() == "pickle":
578
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
185 encoding = self.attribute("encoding")
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
186 if encoding != "base64":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
187 self.raiseError(QCoreApplication.translate(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
188 "XMLStreamReaderBase",
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
189 "Pickle data encoding '{0}' is not"
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
190 " supported.").format(encoding))
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
191 continue
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
192 b64 = self.readElementText()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
193 pic = base64.b64decode(b64.encode("ASCII"))
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
194 val = pickle.loads(pic)
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 else:
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 self._skipUnknownElement()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 except ValueError as err:
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 self.raiseError(str(err))
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
199 continue
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
200
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
201 if self.isEndElement():
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
202 if self.name() in [
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
203 "tuple", "list", "dict", "set", "frozenset"]:
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
204 return None
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
205 else:
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
206 return val
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
207
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
208 def __readTuple(self):
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
209 """
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
210 Private method to read a Python tuple.
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
211
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
212 @return Python tuple
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
213 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
214 li = []
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
215 while not self.atEnd():
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
216 val = self._readBasics()
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
217 if self.isEndElement() and self.name() == "tuple" and val is None:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
218 return tuple(li)
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
219 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
220 li.append(val)
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
221
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
222 def __readList(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
223 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
224 Private method to read a Python list.
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
225
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
226 @return Python list
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
227 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
228 li = []
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
229 while not self.atEnd():
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
230 val = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
231 if self.isEndElement() and self.name() == "list" and val is None:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
232 return li
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
233 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
234 li.append(val)
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
235
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
236 def __readDict(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
237 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
238 Private method to read a Python dictionary.
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
239
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
240 @return Python dictionary
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
241 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
242 d = {}
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
243 while not self.atEnd():
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
244 self.readNext()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
245 if self.isStartElement():
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
246 if self.name() == "key":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
247 key = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
248 elif self.name() == "value":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
249 d[key] = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
250 if self.isEndElement() and self.name() == "dict":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
251 self.readNext()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
252
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
253 if self.isEndElement() and self.name() == "dict":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
254 return d
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
255
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
256 def __readSet(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
257 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
258 Private method to read a Python set.
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
259
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
260 @return Python set
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
261 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
262 li = []
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
263 while not self.atEnd():
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
264 val = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
265 if self.isEndElement() and self.name() == "set" and val is None:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
266 return set(li)
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
267 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
268 li.append(val)
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
269
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
270 def __readFrozenset(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
271 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
272 Private method to read a Python set.
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
273
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
274 @return Python set
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
275 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
276 li = []
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
277 while not self.atEnd():
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
278 val = self._readBasics()
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
279 if self.isEndElement() and \
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
280 self.name() == "frozenset" and \
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
281 val is None:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
282 return frozenset(li)
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
283 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
284 li.append(val)

eric ide

mercurial