eric6/E5XML/XMLStreamReaderBase.py

Sun, 02 Feb 2020 11:04:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 Feb 2020 11:04:32 +0100
changeset 7380
c99320e859ca
parent 7360
9190402e4505
child 7628
f904d0eef264
permissions
-rw-r--r--

Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.

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

eric ide

mercurial