def enableDisable(self, filetype): """Enable or disable controls as appropriate.""" enabled = (filetype in DocReader.supportedNames()) self.lblParaStyle.getModel().Enabled = enabled self.lblCharStyle.getModel().Enabled = enabled self.lblFont.getModel().Enabled = enabled self.comboParaStyle.getModel().Enabled = enabled self.comboCharStyle.getModel().Enabled = enabled self.comboFont.getModel().Enabled = enabled self.optFontTypeWestern.getModel().Enabled = enabled self.optFontTypeComplex.getModel().Enabled = enabled self.optFontTypeAsian.getModel().Enabled = enabled enabled = (filetype in PhonReader.supportedNames() or filetype in InterlinReader.supportedNames() or filetype in CalcFileReader.supportedNames() or filetype in DocReader.supportedNames()) self.lblWhatToGrab.getModel().Enabled = enabled self.listWhatToGrab.getModel().Enabled = enabled enabled = (filetype in CalcFileReader.supportedNames()) self.checkboxSkipRow.getModel().Enabled = enabled enabled = (filetype == 'spellingStatus') self.lblAddItem.getModel().Enabled = not enabled self.lblFields.getModel().Enabled = not enabled self.listboxFields.getModel().Enabled = not enabled self.btnAdd.getModel().Enabled = not enabled self.btnRemove.getModel().Enabled = not enabled self.checkboxMiss.getModel().Enabled = enabled enabled = (filetype in SFM_Reader.supportedNames()) self.lblSFM.getModel().Enabled = enabled self.txtSFM.getModel().Enabled = enabled enabled = (filetype == 'lift') self.txtWS.getModel().Enabled = enabled self.lblWS.getModel().Enabled = enabled self.btnSelectWS.getModel().Enabled = enabled
def fieldItemToAdd(self, itemPos): """Create a field item to be added.""" newObj = WhatToGrab(self.userVars) if itemPos >= 0: key, dummy_display = self.titles[itemPos] newObj.whichOne = key if self.filetype in CalcFileReader.supportedNames(): newObj.grabType = WhatToGrab.COLUMN elif self.filetype in DocReader.supportedNames(): newObj.grabType = WhatToGrab.PART else: newObj.grabType = WhatToGrab.FIELD logger.debug( util.funcName('end', args=(newObj.whichOne, newObj.grabType))) return newObj
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
def fillFieldList(self): """Fills listWhatToGrab based on self.filetype.""" count = self.dlgCtrls.listWhatToGrab.getItemCount() self.dlgCtrls.listWhatToGrab.removeItems(0, count) self.titles = [("", "")] if self.filetype in PhonReader.supportedNames(): self.titles.extend(lingex_structs.LingPhonExample.GRAB_FIELDS) elif self.filetype in InterlinReader.supportedNames(): self.titles.extend(lingex_structs.LingGramExample.GRAB_FIELDS) elif self.filetype in DocReader.supportedNames(): self.titles.append((WhatToGrab.WHOLE_DOC, "Whole Document")) elif self.filetype in CalcFileReader.supportedNames(): for char in string.ascii_uppercase: self.titles.append( (char, "%s %s" % (theLocale.getText("Column"), char))) if len(self.titles) > 1: stringList = [ theLocale.getText(display) for dummy_key, display in self.titles ] self.dlgCtrls.listWhatToGrab.addItems(tuple(stringList), 0)