eric6/E5XML/XMLStreamReaderBase.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7780
41420f82c0ac
child 8218
7c09585bd960
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
3 # Copyright (c) 2010 - 2021 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 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
7 Module implementing a base class for all of eric6s XML stream writers.
574
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
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
10 import pickle # secok
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import base64
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3178
diff changeset
13 from PyQt5.QtCore import QXmlStreamReader, QCoreApplication
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
15 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
16
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
17
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 class XMLStreamReaderBase(QXmlStreamReader):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
20 Class implementing a base class for all of eric6s XML stream readers.
574
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 def __init__(self, device):
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 Constructor
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 @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
27 """
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
28 super(XMLStreamReaderBase, self).__init__(device)
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
592
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
30 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
31 """
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
32 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
33
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
34 @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
35 @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
36 """
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
37 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
38 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
39
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
40 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
41 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
42
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
43 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
44 return None
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
45
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
46 def showErrorMessage(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
47 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
48 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
49 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
50 if self.hasError():
5870
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
51 if self.device() is not None:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
52 msg = QCoreApplication.translate(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
53 "XMLStreamReaderBase",
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
54 "<p>XML parse error in file <b>{0}</b>, line {1},"
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
55 " column {2}</p><p>Error: {3}</p>").format(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
56 self.device().fileName(),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
57 self.lineNumber(), self.columnNumber(),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
58 self.errorString())
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
59 else:
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
60 msg = QCoreApplication.translate(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
61 "XMLStreamReaderBase",
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
62 "<p>XML parse error (line {0},"
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
63 " column {1})</p><p>Error: {2}</p>").format(
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
64 self.lineNumber(), self.columnNumber(),
82e04c70f969 Finished implementing a downloader and installer/uninstaller for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
65 self.errorString())
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
66 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
67 None,
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
68 QCoreApplication.translate(
3035
36e9f388958b Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
69 "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
70 msg)
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
71
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
72 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
73 """
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
74 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
75
589
a9a4620f6767 Added code to handle unexpected start tags to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 578
diff changeset
76 @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
77 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
78 self.raiseError(QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
79 "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
80
590
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
81 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
82 """
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
83 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
84
beb60b9b3d8d Added code to handle unsupported versions to the new XML readers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 589
diff changeset
85 @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
86 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
87 self.raiseError(QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
88 "XMLStreamReaderBase",
604
a2671d497b49 Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 592
diff changeset
89 "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
90
592
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
91 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
92 """
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
93 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
94
3ad07054e658 Extended the stream reader API and adjusted the tasks reader accordingly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 590
diff changeset
95 @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
96 """
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
97 self.raiseError(QCoreApplication.translate(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
98 "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
99
578
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
100 def readXML(self):
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 and parse the XML document.
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 pass
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
105
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
106 def attribute(self, name, default=""):
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 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
109
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
110 @param name name of the attribute (string)
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
111 @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
112 @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
113 """
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
114 att = self.attributes().value(name)
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
115 if att == "":
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
116 att = default
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
117 return att
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
118
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 def _skipUnknownElement(self):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 Protected method to skip over all unknown elements.
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 if not self.isStartElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 return
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 while not self.atEnd():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.readNext()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 if self.isEndElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 break
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 if self.isStartElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 self._skipUnknownElement()
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 def _readBasics(self):
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 """
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
136 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
137
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @return Python object read
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 while not self.atEnd():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 self.readNext()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 if self.isStartElement():
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 try:
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if self.name() == "none":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
145 val = None
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 elif self.name() == "int":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
147 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
148 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
149 # backward compatibility to 4.6
617
97baf3ff9d9d Added some compatibility code to XMLStreamReaderBase.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 605
diff changeset
150 val = int(self.readElementText())
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 elif self.name() == "bool":
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 b = self.readElementText()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 if b == "True":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
154 val = True
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 else:
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
156 val = False
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 elif self.name() == "float":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
158 val = float(self.readElementText())
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 elif self.name() == "complex":
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 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
161 val = float(real) + float(imag) * 1j
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 elif self.name() == "string":
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
163 val = self.readElementText()
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 elif self.name() == "bytes":
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
165 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
166 self.readElementText().split(",")])
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
167 val = by
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 elif self.name() == "bytearray":
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
169 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
170 self.readElementText().split(",")])
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
171 val = by
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
172 elif self.name() == "tuple":
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
173 val = self.__readTuple()
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
174 return val
577
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() == "list":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
176 val = self.__readList()
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() == "dict":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
179 val = self.__readDict()
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() == "set":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
182 val = self.__readSet()
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() == "frozenset":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
185 val = self.__readFrozenset()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
186 return val
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
187 elif self.name() == "pickle":
578
a0ecb2c68208 Extended the stream reader base class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 577
diff changeset
188 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
189 if encoding != "base64":
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
190 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
191 "XMLStreamReaderBase",
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2953
diff changeset
192 "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
193 " 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
194 continue
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
195 b64 = self.readElementText()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
196 pic = base64.b64decode(b64.encode("ASCII"))
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
197 val = pickle.loads(pic) # secok
574
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 else:
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self._skipUnknownElement()
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 except ValueError as err:
c45f896e4c66 Started implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 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
202 continue
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
203
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
204 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
205 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
206 "tuple", "list", "dict", "set", "frozenset"]:
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
207 return None
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
208 else:
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
209 return val
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
210
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
211 def __readTuple(self):
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
212 """
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
213 Private method to read a Python tuple.
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
214
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
215 @return Python tuple
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
216 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
217 li = []
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
218 while not self.atEnd():
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
219 val = self._readBasics()
576
ad8fdac5aff5 Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 575
diff changeset
220 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
221 return tuple(li)
575
5a008db344ea Continued implementing the XMLStreamReaderBase class.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 574
diff changeset
222 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
223 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
224
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
225 def __readList(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
226 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
227 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
228
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
229 @return Python list
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
230 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
231 li = []
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
232 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
233 val = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
234 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
235 return li
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
236 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
237 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
238
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
239 def __readDict(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
240 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
241 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
242
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
243 @return Python dictionary
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
244 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
245 d = {}
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
246 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
247 self.readNext()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
248 if self.isStartElement():
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
249 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
250 key = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
251 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
252 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
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 self.readNext()
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 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
257 return d
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
258
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
259 def __readSet(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
260 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
261 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
262
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
263 @return Python set
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
264 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
265 li = []
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
266 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
267 val = self._readBasics()
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
268 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
269 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
270 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
271 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
272
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
273 def __readFrozenset(self):
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
274 """
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
275 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
276
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
277 @return Python set
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
278 """
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
279 li = []
577
ef42a81128ca Finished the XML stream reader for basic Python data types.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 576
diff changeset
280 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
281 val = self._readBasics()
7253
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
282 if (
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
283 self.isEndElement() and
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
284 self.name() == "frozenset" and
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
285 val is None
50dbe65a1334 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
286 ):
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
287 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
288 else:
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
289 li.append(val)

eric ide

mercurial