本文整理匯總了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'])
#.........這裏部分代碼省略.........