def setUp(self): unoObjs = testutil.unoObjsForCurrentDoc() fileconfig = fileitemlist.WordListFileItem(None) docReader = DocReader(fileconfig, unoObjs, -1) docReader.loadDoc(self.INFILE) self.unoObjs = docReader.doc testutil.stored.doc = self.unoObjs.document self.progressBar = ProgressBar(self.unoObjs, "TestSearch")
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