示例#1
0
 def read_spellingStatus_file(self):
     """Modifies self.data"""
     logger.debug("reading Spelling Status file")
     statuses = self.dom.getElementsByTagName("Status")
     for status in statuses:
         if not status.attributes:
             continue
         text = status.getAttribute("Word")
         state = status.getAttribute("State")
         if not text:
             continue
         word = wordlist_structs.WordInList()
         word.text = text
         word.source = self.filepath
         if state == "R":
             word.isCorrect = True
         elif state == "W":
             word.isCorrect = False
             if not self.fileconfig.includeMisspellings:
                 continue
             correction = xmlutil.getTextByTagName(status, "Correction")
             if correction:
                 word.correction = correction
                 logger.debug("got correction")
         self.data.append(word)
     logger.debug("finished reading file")
示例#2
0
 def _read(self):
     """Read in the data.  Modifies self.data"""
     logger.debug("Parsing file %s", self.filepath)
     if not os.path.exists(self.filepath):
         raise exceptions.FileAccessError(
             "Cannot find file %s", self.filepath)
     self.progressBar.updatePercent(30)
     self.read_sfm_file()
     for dummy_marker, value in self.rawData:
         word = wordlist_structs.WordInList()
         word.text = value
         word.source = self.filepath
         self.data.append(word)
 def grabWords(self, thingsToGrab):
     """Return values in a flat list of words."""
     self.generateRefIDs = True
     self.read()
     words = []
     for phonEx in self.data.values():
         for whatToGrab in thingsToGrab:
             if whatToGrab.grabType == wordlist_structs.WhatToGrab.FIELD:
                 try:
                     newList = phonEx.grabList(whatToGrab.whichOne)
                 except exceptions.LogicError as exc:
                     self.msgbox.displayExc(exc)
                     return words
                 for text in newList:
                     newWord = wordlist_structs.WordInList()
                     newWord.text = text
                     newWord.source = self.filepath
                     words.append(newWord)
     logger.debug("got %d words", len(words))
     return words
 def _read(self):
     """Harvest data by grabbing word strings from one or more columns."""
     try:
         self.loadDoc(self.filepath)
     except (exceptions.FileAccessError, exceptions.DocAccessError):
         raise exceptions.FileAccessError("Error reading file %s",
                                          self.filepath)
     reader = SpreadsheetReader(self.calcUnoObjs)
     self.progressBar.updatePercent(60)
     for whatToGrab in self.fileconfig.thingsToGrab:
         if whatToGrab.grabType == wordlist_structs.WhatToGrab.COLUMN:
             stringList = reader.getColumnStringList(
                 whatToGrab.whichOne, self.fileconfig.skipFirstRow)
             for text in stringList:
                 if text != "":
                     ## Add word
                     word = wordlist_structs.WordInList()
                     word.text = text
                     word.source = self.filepath
                     self.data.append(word)
     logger.debug("Setting visible.")
     self.calcUnoObjs.window.setVisible(True)