예제 #1
0
 def updateFile(self, selectNewItem):
     logger.debug(util.funcName('begin'))
     if not 0 <= self.selectedIndex < len(self.fileItems):
         if selectNewItem:
             self.msgbox.displayExc(self.fileItems.noItemSelected())
         else:
             logger.debug(util.funcName('return'))
         return
     newItem = fileitemlist.LingExFileItem(self.userVars)
     newItem.filepath = self.fileItems[self.selectedIndex].filepath
     newItem.setPrefixNoSpaces(self.dlgCtrls.txtPrefix.getText())
     newItem.use_segnum = bool(self.dlgCtrls.chkUseSegnum.getState())
     oldItem = self.fileItems[self.selectedIndex]
     if oldItem:
         if (newItem.filepath == oldItem.filepath
                 and newItem.prefix == oldItem.prefix
                 and newItem.use_segnum == oldItem.use_segnum):
             logger.debug(
                 util.funcName('return',
                               args="%s same as %s" % (newItem, oldItem)))
             return
         logger.debug("%s not same as %s", newItem, oldItem)
         try:
             self.fileItems.updateItem(self.selectedIndex, newItem)
         except exceptions.ChoiceProblem as exc:
             self.msgbox.displayExc(exc)
             return
     if selectNewItem:
         self.refreshListAndSelectItem(newItem)
     else:
         self.refreshList()
     logger.debug(util.funcName('end'))
예제 #2
0
 def test1_item_types(self):
     if HAS_MOCK:
         userVars = mock.Mock()
     else:
         userVars = None
     dummy_item = fileitemlist.BulkFileItem(userVars)
     dummy_item = fileitemlist.WordListFileItem(userVars)
     dummy_item = fileitemlist.LingExFileItem(userVars)
예제 #3
0
 def addFile(self):
     logger.debug(util.funcName('begin'))
     filepath = filepicker.showFilePicker(self.unoObjs)
     if filepath != "":
         newItem = fileitemlist.LingExFileItem(self.userVars)
         newItem.filepath = filepath
         try:
             logger.debug("Adding item '%s'", str(newItem))
             self.fileItems.addItem(newItem)
         except exceptions.ChoiceProblem as exc:
             self.msgbox.displayExc(exc)
             return
         self.refreshListAndSelectItem(newItem)
     logger.debug(util.funcName('end'))
 def _harvestWords(self, fileItem):
     """Harvest words from the specified file."""
     fileType = fileItem.filetype  # short variable name
     logger.debug(util.funcName(args=fileType))
     words = []
     if fileType in WordsReader.supportedNames():
         reader = WordsReader(fileItem, self.unoObjs)
         words = reader.read()
     elif fileType in SFM_Reader.supportedNames():
         reader = SFM_Reader(fileItem, self.unoObjs)
         words = reader.read()
     elif fileType in InterlinReader.supportedNames():
         config = fileitemlist.InterlinInputSettings(self.userVars)
         config.showMorphLine2 = True
         config.separateMorphColumns = True
         lingExFileItem = fileitemlist.LingExFileItem(self.userVars)
         lingExFileItem.filepath = fileItem.filepath
         config.fileList.addItem(lingExFileItem)
         reader = InterlinReader(self.unoObjs, self.userVars, config)
         words = reader.grabWords(fileItem.thingsToGrab)
     elif fileType in PhonReader.supportedNames():
         config = lingex_structs.PhonInputSettings(self.userVars)
         config.filepath = fileItem.filepath
         config.phoneticWS = fileItem.writingSystem
         config.isLexemePhonetic = True
         phonUserVars = UserVars(
             Prefix.PHONOLOGY, self.unoObjs.document, logger)
         if phonUserVars.get("FlexLexeme") == 'phonemic':
             config.isLexemePhonetic = False
         reader = PhonReader(self.unoObjs, self.userVars, config)
         words = reader.grabWords(fileItem.thingsToGrab)
     elif fileType in DocReader.supportedNames():
         settings = TextSearchSettings()
         settings.load_userVars(self.userVars)
         reader = DocReader(fileItem, self.unoObjs, settings.matchesLimit)
         words = reader.read()
     elif fileType in CalcFileReader.supportedNames():
         reader = CalcFileReader(self.unoObjs)
         reader.setFileConfig(fileItem)
         words = reader.read()
     return words