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 storeUserVars(self):
     self.punctToRemove = self.dlgCtrls.txtRemovePunct.getText()
     self.userVars.store("Punctuation", self.punctToRemove)
     self.normForm = self.userVars.get('NormForm')
     self.columnOrder.storeUserVars()
     for fileItem in self.fileItems:
         if fileItem.filetype in PhonReader.supportedNames():
             uservars.InterlinTags(self.userVars).loadUserVars()
             break
     for fileItem in self.fileItems:
         if fileItem.filetype in InterlinReader.supportedNames():
             uservars.PhonologyTags(self.userVars).loadUserVars()
             break
Exemplo n.º 3
0
 def readData(self):
     """
     Read examples from data files.
     """
     if self.examplesDict is None:
         logger.debug("Getting examples dict")
         if self.exType == EXTYPE_PHONOLOGY:
             fileReader = PhonReader(
                 self.unoObjs, self.userVars, self.settings.getInconfig())
         else:
             fileReader = InterlinReader(
                 self.unoObjs, self.userVars, self.settings.getInconfig())
         self.examplesDict = fileReader.read()
         self.suggestions = fileReader.getSuggestions()
 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)
    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