E5XML/XMLStreamReaderBase.py

changeset 592
3ad07054e658
parent 590
beb60b9b3d8d
child 604
a2671d497b49
equal deleted inserted replaced
591:c92803caf37f 592:3ad07054e658
34 Public method to decode newlines and paragraph breaks. 34 Public method to decode newlines and paragraph breaks.
35 35
36 @param text text to decode (string) 36 @param text text to decode (string)
37 """ 37 """
38 return text.replace(self.NEWPARA, "\n\n").replace(self.NEWLINE, "\n") 38 return text.replace(self.NEWPARA, "\n\n").replace(self.NEWLINE, "\n")
39
40 def toBool(self, value):
41 """
42 Public method to convert the given value to bool.
43
44 @param value value to be converted ("True", "False", "1", "0")
45 @return converted value (boolean) or None in case of an error
46 """
47 if value.lower() in ["true", "false"]:
48 return value.lower() == "true"
49
50 if value in ["1", "0"]:
51 return bool(int(value))
52
53 self.raiseBadValue(value)
54 return None
39 55
40 def showErrorMessage(self): 56 def showErrorMessage(self):
41 """ 57 """
42 Public method to show an error message. 58 Public method to show an error message.
43 """ 59 """
65 81
66 @param version unsupported version (string) 82 @param version unsupported version (string)
67 """ 83 """
68 self.raiseError(QCoreApplication.translate("XMLStreamReaderBase", 84 self.raiseError(QCoreApplication.translate("XMLStreamReaderBase",
69 "File format version '{0}' is not supported.".format(version))) 85 "File format version '{0}' is not supported.".format(version)))
86
87 def raiseBadValue(self, value):
88 """
89 Public method to raise an error for a bad value.
90
91 @param value bad value (string)
92 """
93 self.raiseError(QCoreApplication.translate("XMLStreamReaderBase",
94 "Bad value: {0}".format(value)))
70 95
71 def readXML(self): 96 def readXML(self):
72 """ 97 """
73 Public method to read and parse the XML document. 98 Public method to read and parse the XML document.
74 """ 99 """

eric ide

mercurial