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


Python Tools.isProject方法代码示例

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


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

示例1: ProjEdit

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

    def __init__(self, pid) :
        '''Intitate the whole class and create the object.'''

        self.pid            = pid
        self.tools          = Tools()
        self.rapumaHome     = os.environ.get('RAPUMA_BASE')
        self.userHome       = os.environ.get('RAPUMA_USER')
        self.user           = UserConfig(self.rapumaHome, self.userHome)
        self.userConfig     = self.user.userConfig
        self.projectConfig     = Config(pid).projectConfig
        self.projHome       = None
        self.local          = None

        self.finishInit()

        # Log messages for this module
        self.errorCodes     = {
            'EDIT-000' : ['MSG', 'Messages for editing project and setting files.'],
            'EDIT-005' : ['MSG', 'Unassigned error message ID.'],
            'EDIT-010' : ['ERR', 'The component [<<1>>] has multiple subcomponents and cannot be opened for editing. Please work with the individual subcomponents.'],
            'EDIT-020' : ['ERR', 'Working text file [<<1>>] not found.'],
            'EDIT-030' : ['ERR', 'No files found to edit with the commands supplied.'],
            'EDIT-040' : ['MSG', 'Component files for [<<1>>] have been opened in your file editor.'],

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


    def finishInit (self, projHome = None) :
        '''Finishing collecting settings that would be needed for most
        functions in this module.'''

        # Look for an existing project home path
        if self.tools.isProject(self.pid) :
            localProjHome   = os.path.join(self.userConfig['Resources']['projects'], self.pid)
        else :
            localProjHome   = ''
        # Testing: The local project home wins over a user provided one
        if localProjHome and not projHome :
            self.projHome   = localProjHome
        elif projHome :
            self.projHome   = projHome
        
        # If a projHome was succefully found, we can go on
        if self.projHome : 
            self.local      = ProjLocal(self.rapumaHome, self.userHome, self.projHome)


###############################################################################
################################ Edit Functions ###############################
###############################################################################
####################### Error Code Block Series = 0200 ########################
###############################################################################


# FIXME: Still lots to do on this next function

    def edit (self, gid, cName = None, glob = False, sys = False) :
        '''Call editing application to edit various project and system files.'''

        editDocs = ['gedit']
        # If a subcomponent is called, pull it up and its dependencies
        # This will not work with components that have more than one
        # subcomponent.
        if cName :
            # Probably need to create the component object now
            self.createComponent(cName)

            cid = self.components[cName].getUsfmCid(cName)

            cType = self.groups[gid].getComponentType(gid)
            self.buildComponentObject(cType, cid)
            cidList = self.groups[gid].getSubcomponentList(gid)
            if len(cidList) > 1 :
                self.log.writeToLog('EDIT-010', [cid])
                self.tools.dieNow()

            self.createManager('text')
            compWorkText = self.groups[gid].getCidPath(cid)
            if os.path.isfile(compWorkText) :
                editDocs.append(compWorkText)
                compTextAdj = self.components[cName].getCidAdjPath(cid)
                compTextIlls = self.components[cName].getCidPiclistPath(cid)
                dep = [compTextAdj, compTextIlls]
                for d in dep :
                    if os.path.isfile(d) :
                        editDocs.append(d)
            else :
                self.log.writeToLog('EDIT-020', [self.tools.fName(compWorkText)])
                self.tools.dieNow()

        # Look at project global settings
        if glob :
            for files in os.listdir(self.local.projConfFolder):
                if files.endswith(".conf"):
                    editDocs.append(os.path.join(self.local.projConfFolder, files))

            globSty = os.path.join(self.local.projStyleFolder, self.projectConfig['Managers']['usfm_Style']['mainStyleFile'])
#.........这里部分代码省略.........
开发者ID:jstnlth,项目名称:rapuma,代码行数:103,代码来源:proj_edit.py


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