E5XML/SpellCheckDictionariesReader.py

changeset 5870
82e04c70f969
parent 5868
c1a98c164cd3
child 5873
331a5ece2c32
equal deleted inserted replaced
5869:70709a460358 5870:82e04c70f969
32 XMLStreamReaderBase.__init__(self, data) 32 XMLStreamReaderBase.__init__(self, data)
33 33
34 self.__entryCallback = entryCallback 34 self.__entryCallback = entryCallback
35 35
36 self.version = "" 36 self.version = ""
37 self.baseUrl = ""
37 38
38 def readXML(self): 39 def readXML(self):
39 """ 40 """
40 Public method to read and parse the XML document. 41 Public method to read and parse the XML document.
41 """ 42 """
44 if self.isStartElement(): 45 if self.isStartElement():
45 if self.name() == "Dictionaries": 46 if self.name() == "Dictionaries":
46 self.version = self.attribute( 47 self.version = self.attribute(
47 "version", 48 "version",
48 dictionariesListFileFormatVersion) 49 dictionariesListFileFormatVersion)
50 self.baseUrl = self.attribute("baseurl", "")
49 if self.version not in self.supportedVersions: 51 if self.version not in self.supportedVersions:
50 self.raiseUnsupportedFormatVersion(self.version) 52 self.raiseUnsupportedFormatVersion(self.version)
51 elif self.name() == "DictionariesUrl": 53 elif self.name() == "DictionariesUrl":
52 url = self.readElementText() 54 url = self.readElementText()
53 Preferences.setWebBrowser("SpellCheckDictionariesUrl", url) 55 Preferences.setWebBrowser("SpellCheckDictionariesUrl", url)
61 def __readDictionary(self): 63 def __readDictionary(self):
62 """ 64 """
63 Private method to read the plug-in info. 65 Private method to read the plug-in info.
64 """ 66 """
65 dictionaryInfo = {"short": "", 67 dictionaryInfo = {"short": "",
66 "filename": "", 68 "filename": "",
67 } 69 "documentation": "",
70 "locales": [],
71 }
68 72
69 while not self.atEnd(): 73 while not self.atEnd():
70 self.readNext() 74 self.readNext()
71 if self.isEndElement() and self.name() == "Dictionary": 75 if self.isEndElement() and self.name() == "Dictionary":
72 self.__entryCallback( 76 self.__entryCallback(
73 dictionaryInfo["short"], dictionaryInfo["filename"]) 77 dictionaryInfo["short"], dictionaryInfo["filename"],
78 self.baseUrl + dictionaryInfo["filename"],
79 dictionaryInfo["documentation"], dictionaryInfo["locales"])
74 break 80 break
75 81
76 if self.isStartElement(): 82 if self.isStartElement():
77 if self.name() == "Short": 83 if self.name() == "Short":
78 dictionaryInfo["short"] = self.readElementText() 84 dictionaryInfo["short"] = self.readElementText()
79 elif self.name() == "Filename": 85 elif self.name() == "Filename":
80 dictionaryInfo["filename"] = self.readElementText() 86 dictionaryInfo["filename"] = self.readElementText()
87 elif self.name() == "Documentation":
88 dictionaryInfo["documentation"] = self.readElementText()
89 elif self.name() == "Locales":
90 dictionaryInfo["locales"] = self.readElementText().split()
81 else: 91 else:
82 self.raiseUnexpectedStartTag(self.name()) 92 self.raiseUnexpectedStartTag(self.name())

eric ide

mercurial