当前位置: 首页>>代码示例>>Python>>正文


Python Tools.getPersistantSettings方法代码示例

本文整理汇总了Python中rapuma.core.tools.Tools.getPersistantSettings方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.getPersistantSettings方法的具体用法?Python Tools.getPersistantSettings怎么用?Python Tools.getPersistantSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rapuma.core.tools.Tools的用法示例。


在下文中一共展示了Tools.getPersistantSettings方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Fixed

# 需要导入模块: from rapuma.core.tools import Tools [as 别名]
# 或者: from rapuma.core.tools.Tools import getPersistantSettings [as 别名]
class Fixed (Manager) :

    # Shared values
    xmlConfFile     = 'fixed.xml'

    def __init__(self, project, cfg, cType) :
        '''Do the primary initialization for this manager.'''

        super(Fixed, self).__init__(project, cfg)

        # Set values for this manager
        self.gid                    = project.gid
        self.pid                    = project.projectIDCode
        self.tools                  = Tools()
        self.project                = project
        self.projectConfig          = project.projectConfig
        self.cfg                    = cfg
        self.cType                  = cType
        self.Ctype                  = cType.capitalize()
        self.log                    = project.log
        self.manager                = self.cType + '_Fixed'
        self.managers               = project.managers
        self.rapumaXmlTextConfig    = os.path.join(self.project.local.rapumaConfigFolder, self.xmlConfFile)

#        import pdb; pdb.set_trace()

        # Get persistant values from the config if there are any
        newSectionSettings = self.tools.getPersistantSettings(self.project.projectConfig['Managers'][self.manager], self.rapumaXmlTextConfig)
        if newSectionSettings != self.project.projectConfig['Managers'][self.manager] :
            self.project.projectConfig['Managers'][self.manager] = newSectionSettings
            self.tools.writeConfFile(self.project.projectConfig)

        self.compSettings = self.project.projectConfig['Managers'][self.manager]

        for k, v in self.compSettings.iteritems() :
            setattr(self, k, v)

        # Log messages for this module
        self.errorCodes     = {

            '0000' : ['MSG', 'Placeholder message'],

        }
开发者ID:jstnlth,项目名称:rapuma,代码行数:45,代码来源:fixed.py

示例2: Text

# 需要导入模块: from rapuma.core.tools import Tools [as 别名]
# 或者: from rapuma.core.tools.Tools import getPersistantSettings [as 别名]
class Text (Manager) :

    # Shared values
    xmlConfFile     = 'text.xml'

    def __init__(self, project, cfg, cType) :
        '''Do the primary initialization for this manager.'''

        super(Text, self).__init__(project, cfg)

        # Set values for this manager
        self.gid                    = project.gid
        self.pid                    = project.projectIDCode
        self.tools                  = Tools()
        self.project                = project
        self.projectConfig          = project.projectConfig
        self.cfg                    = cfg
        self.cType                  = cType
        self.Ctype                  = cType.capitalize()
        self.log                    = project.log
        self.manager                = self.cType + '_Text'
        self.managers               = project.managers
        self.rapumaXmlTextConfig    = os.path.join(self.project.local.rapumaConfigFolder, self.xmlConfFile)

#        import pdb; pdb.set_trace()

        # Get persistant values from the config if there are any
        newSectionSettings = self.tools.getPersistantSettings(self.project.projectConfig['Managers'][self.manager], self.rapumaXmlTextConfig)
        if newSectionSettings != self.project.projectConfig['Managers'][self.manager] :
            self.project.projectConfig['Managers'][self.manager] = newSectionSettings
            self.tools.writeConfFile(self.project.projectConfig)

        self.compSettings = self.project.projectConfig['Managers'][self.manager]

        for k, v in self.compSettings.iteritems() :
            setattr(self, k, v)

        # Log messages for this module
        self.errorCodes     = {

            'TEXT-000' : ['MSG', 'Text module messages'],
            'TEXT-005' : ['ERR', 'Component type [<<1>>] is not supported by the text manager.'],
            'TEXT-015' : ['MSG', 'TEXT-015 - Unassigned error message ID.'],
            'TEXT-030' : ['LOG', 'Copied [<<1>>] to [<<2>>] in project.'],
            'TEXT-040' : ['WRN', 'The [<<1>>] component is locked. It must be unlocked before any modifications can be made.'],
            'TEXT-050' : ['LOG', 'Working text file for [<<1>>] has been completed.'],
            'TEXT-055' : ['ERR', 'TEXT-055 - Unassigned error message ID.'],
            'TEXT-080' : ['LOG', 'Validating text using the [<<1>>] style file.'],
            'TEXT-150' : ['MSG', 'USFM file: [<<1>>] is valid.'],
            'TEXT-160' : ['ERR', 'Unable to complete working text installation for [<<1>>]. May require \"force\" (-f).'],

            '0000' : ['MSG', 'Placeholder message'],

        }

###############################################################################
############################ Project Level Functions ##########################
###############################################################################


#    def setSourceEditor (self, editor) :
#        '''Set the source editor for the cType. It assumes the editor is valid.
#        This cannot fail.'''

#        se = ''
#        if self.project.projectConfig['CompTypes'][self.Ctype].has_key('sourceEditor') :
#            se = self.project.projectConfig['CompTypes'][self.Ctype]['sourceEditor']

#        if se != editor :
#            self.project.projectConfig['CompTypes'][self.Ctype]['sourceEditor'] = editor
#            self.tools.writeConfFile(self.project.projectConfig)


# FIXME: Get rid of the PT dependencies

    #def updateManagerSettings (self, gid) :
        #'''Update the settings for this manager if needed.'''

##        import pdb; pdb.set_trace()

        #sourceEditor = self.pt_tools.getSourceEditor()

        ## If the source editor is PT, then a lot of information can be
        ## gleaned from the .ssf file. Otherwise we will go pretty much with
        ## the defaults and hope for the best.
        #if sourceEditor.lower() == 'paratext' :
            ## Do a compare on the settings
            #ptSet = self.pt_tools.getPTSettings()
            #oldCompSet = self.compSettings.dict()
            ## Don't overwrite manager settings (default sets reset to False) if
            ## there already is a setting present on the nameFormID.
            #if self.project.projectConfig['Managers'][self.cType + '_Text']['nameFormID'] :
                #newCompSet = self.pt_tools.mapPTTextSettings(self.compSettings.dict(), ptSet)
            #else :
                #newCompSet = self.pt_tools.mapPTTextSettings(self.compSettings.dict(), ptSet, True)

            #if not newCompSet == oldCompSet :
                #self.compSettings.merge(newCompSet)
                #self.tools.writeConfFile(self.project.projectConfig)
                ## Be sure to update the current session settings
#.........这里部分代码省略.........
开发者ID:jstnlth,项目名称:rapuma,代码行数:103,代码来源:text.py

示例3: Pdf

# 需要导入模块: from rapuma.core.tools import Tools [as 别名]
# 或者: from rapuma.core.tools.Tools import getPersistantSettings [as 别名]
class Pdf (Group) :
    '''This class contains information about a type of component 
    used in a type of project.'''

    # Shared values
    xmlConfFile     = 'pdf.xml'

    def __init__(self, project, cfg) :
        super(Pdf, self).__init__(project, cfg)

#        import pdb; pdb.set_trace()

        # Set values for this manager
        self.pid                    = project.projectIDCode
        self.gid                    = project.gid
        self.cType                  = 'pdf'
        self.Ctype                  = self.cType.capitalize()
        self.project                = project
        self.local                  = project.local
        self.tools                  = Tools()
        self.proj_config            = Config(self.pid, self.gid)
        self.proj_config.getProjectConfig()
        self.proj_config.getAdjustmentConfig()
        self.projectConfig          = self.proj_config.projectConfig
        self.log                    = project.log
        self.cfg                    = cfg
        self.mType                  = project.projectMediaIDCode
        self.renderer               = project.projectConfig['CompTypes'][self.Ctype]['renderer']
        self.compSource             = project.projectConfig['CompTypes'][self.Ctype]['compSource']

        # Get the comp settings
        self.compSettings           = project.projectConfig['CompTypes'][self.Ctype]

        # Build a tuple of managers this component type needs to use
        self.pdfManagers = ('fixed', self.renderer)

        # Init the general managers
        for self.mType in self.pdfManagers :
            self.project.createManager(self.mType)

        # Create the internal ref names we use in this module
        self.text                   = self.project.managers[self.cType + '_Fixed']
        # File names

        # Folder paths
        self.projScriptFolder       = self.local.projScriptFolder
        self.projComponentFolder    = self.local.projComponentFolder
        self.gidFolder              = os.path.join(self.projComponentFolder, self.gid)
        # File names with folder paths
        self.rapumaXmlCompConfig    = os.path.join(self.project.local.rapumaConfigFolder, self.xmlConfFile)

        # Get persistant values from the config if there are any
        newSectionSettings = self.tools.getPersistantSettings(self.projectConfig['CompTypes'][self.Ctype], self.rapumaXmlCompConfig)
        if newSectionSettings != self.projectConfig['CompTypes'][self.Ctype] :
            self.projectConfig['CompTypes'][self.Ctype] = newSectionSettings
        # Set them here
        for k, v in self.compSettings.iteritems() :
            setattr(self, k, v)

        # Module Error Codes
        self.errorCodes     = {

            '0000' : ['MSG', 'Messages for the PDF module.'],

        }


###############################################################################
############################ Functions Begin Here #############################
###############################################################################
######################## Error Code Block Series = 1000 #######################
###############################################################################



    def makeFileNameWithExt(self, cid) :
        '''From what we know, return the full file name.'''

        return self.makeFileName(cid) + '.' + self.cType


    def getCidPath (self, cid) :
        '''Return the full path of the cName working text file. This assumes
        the cid is valid.'''

        return os.path.join(self.local.projComponentFolder, cid, self.makeFileNameWithExt(cid))


    def render(self, gid, cidList, pages, override, save) :
        '''This will join together PDF files in a group. Though we call
        it render, it is more of a merging operation.'''

#        import pdb; pdb.set_trace()

        # If the whole group is being rendered, we need to preprocess it
        cids = []
        if not cidList :
            cids = self.projectConfig['Groups'][gid]['cidList']
        else :
            cids = cidList
#.........这里部分代码省略.........
开发者ID:jstnlth,项目名称:rapuma,代码行数:103,代码来源:pdf.py

示例4: Usfm

# 需要导入模块: from rapuma.core.tools import Tools [as 别名]
# 或者: from rapuma.core.tools.Tools import getPersistantSettings [as 别名]
class Usfm (Group) :
    '''This class contains information about a type of component 
    used in a type of project.'''

    # Shared values
    xmlConfFile     = 'usfm.xml'

    def __init__(self, project, cfg) :
        super(Usfm, self).__init__(project, cfg)

#        import pdb; pdb.set_trace()

        # Set values for this manager
        self.pid                    = project.projectIDCode
        self.gid                    = project.gid
        self.cType                  = 'usfm'
        self.Ctype                  = self.cType.capitalize()
        self.project                = project
        self.local                  = project.local
        self.tools                  = Tools()
        self.proj_font              = ProjFont(self.pid)
        self.proj_illustration      = ProjIllustration(self.pid, self.gid)
        self.proj_config            = Config(self.pid, self.gid)
        self.proj_config.getProjectConfig()
        self.proj_config.getAdjustmentConfig()
        self.projectConfig          = self.proj_config.projectConfig
        self.adjustmentConfig       = self.proj_config.adjustmentConfig
        self.log                    = project.log
        self.cfg                    = cfg
        self.mType                  = project.projectMediaIDCode
        self.renderer               = project.projectConfig['CompTypes'][self.Ctype]['renderer']
        self.sourceEditor           = project.projectConfig['CompTypes'][self.Ctype]['sourceEditor']
        self.macPackId              = project.projectConfig['CompTypes'][self.Ctype]['macroPackage']
        # Get the comp settings
        self.compSettings           = project.projectConfig['CompTypes'][self.Ctype]
        # Build a tuple of managers this component type needs to use
        self.usfmManagers = ('text', self.renderer)

        # Init the general managers
        for self.mType in self.usfmManagers :
            self.project.createManager(self.mType)

        # Create the internal ref names we use in this module
        self.text                   = self.project.managers[self.cType + '_Text']
        # File names

        # Folder paths
        self.projScriptFolder       = self.local.projScriptFolder
        self.projComponentFolder    = self.local.projComponentFolder
        self.gidFolder              = os.path.join(self.projComponentFolder, self.gid)
        # File names with folder paths
        self.rapumaXmlCompConfig    = os.path.join(self.project.local.rapumaConfigFolder, self.xmlConfFile)



        # Get persistant values from the config if there are any
        newSectionSettings = self.tools.getPersistantSettings(self.projectConfig['CompTypes'][self.Ctype], self.rapumaXmlCompConfig)
        if newSectionSettings != self.projectConfig['CompTypes'][self.Ctype] :
            self.projectConfig['CompTypes'][self.Ctype] = newSectionSettings
        # Set them here
        for k, v in self.compSettings.iteritems() :
            setattr(self, k, v)

        # Module Error Codes
        self.errorCodes     = {

            #'USFM-000' : ['MSG', 'Messages for the USFM module.'],
            #'USFM-005' : ['MSG', 'Unassigned error message ID.'],
            #'USFM-010' : ['ERR', 'Could not process character pair. This error was found: [<<1>>]. Process could not complete. - usfm.pt_tools.getNWFChars()'],
            #'USFM-020' : ['ERR', 'Improper character pair found: [<<1>>].  Process could not complete. - usfm.pt_tools.getNWFChars()'],
            #'USFM-025' : ['WRN', 'No non-word-forming characters were found in the PT settings file. - usfm.pt_tools.getNWFChars()'],
            #'USFM-040' : ['ERR', 'Hyphenation source file not found: [<<1>>]. Process halted!'],
            #'USFM-080' : ['LOG', 'Normalizing Unicode text to the [<<1>>] form.'],
            #'USFM-090' : ['ERR', 'USFM file: [<<1>>] did NOT pass the validation test. Because of an encoding conversion, the terminal output is from the file [<<2>>]. Please only edit [<<1>>].'],
            #'USFM-095' : ['WRN', 'Validation for USFM file: [<<1>>] was turned off.'],
            #'USFM-100' : ['MSG', 'Source file editor [<<1>>] is not recognized by this system. Please double check the name used for the source text editor setting.'],
            #'USFM-110' : ['ERR', 'Source file name could not be built because the Name Form ID for [<<1>>] is missing or incorrect. Double check to see which editor created the source text.'],
            #'USFM-120' : ['ERR', 'Source file: [<<1>>] not found! Cannot copy to project. Process halting now.'],
            #'USFM-130' : ['ERR', 'Failed to complete preprocessing on component [<<1>>]'],
            #'USFM-140' : ['MSG', 'Completed installation on [<<1>>] component working text.'],
            #'USFM-150' : ['ERR', 'Unable to copy [<<1>>] to [<<2>>] - error in text.'],

            '0010' : ['LOG', 'Created the [<<1>>] master adjustment file.'],
            '0220' : ['ERR', 'Cannot find: [<<1>>] working file, unable to complete preprocessing for rendering.'],
            '0230' : ['LOG', 'Created the [<<1>>] component adjustment file.'],
            '0240' : ['LOG', 'Could not find adjustments section for [<<1>>], created place holder setting.'],
            '0245' : ['LOG', 'Could not find adjustments for [<<1>>]. No ajustment file has been output.'],
            '0255' : ['LOG', 'Illustrations not being used. The piclist file has been removed from the [<<1>>] illustrations folder.'],
            '0260' : ['LOG', 'Piclist file for [<<1>>] has been created.'],
            '0265' : ['ERR', 'Failed to create piclist file for [<<1>>]!'],
            '0300' : ['ERR', 'One or more illustration files are missing from the project. Please import these files before continuing.']
        }


###############################################################################
############################ Functions Begin Here #############################
###############################################################################
######################## Error Code Block Series = 0200 #######################
###############################################################################

#.........这里部分代码省略.........
开发者ID:jstnlth,项目名称:rapuma,代码行数:103,代码来源:usfm.py


注:本文中的rapuma.core.tools.Tools.getPersistantSettings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。