本文整理匯總了Python中rapuma.core.tools.Tools.isOlder方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.isOlder方法的具體用法?Python Tools.isOlder怎麽用?Python Tools.isOlder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.isOlder方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ProjData
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import isOlder [as 別名]
#.........這裏部分代碼省略.........
projectConfig['Backup']['ownerID'] = projOwnerID
self.tools.writeConfFile(projectConfig)
def buyLocal (self, projectConfig) :
'''Change the ownership on a local project by assigning your
userID to it.'''
projOwnerID = self.userConfig['System']['userID']
projectConfig['Backup']['ownerID'] = projOwnerID
self.tools.writeConfFile(projectConfig)
def replaceProject (self, source, target) :
'''This will completly replace an existing project (target)
with data from another project (source). This assumes
source and target are valid.'''
# We simply just get rid of the target before doing a merge
shutil.rmtree(target)
self.log.writeToLog(self.errorCodes['4150'], [target, source])
self.mergeProjects(source, target)
def mergeProjects(self, source, target) :
'''This will merge two Rapuma projects and try to preserve
data in the target that is newer than the source. This assumes
target and source are valid.'''
# Get a list of files we do not want
excludeFiles = self.makeExcludeFileList(source)
# Get a total list of files from the project
cn = 0
cr = 0
# Add space for output message
sys.stdout.write('\n')
sys.stdout.write('Merging files from: ' + source + ' to: ' + target)
sys.stdout.flush()
for folder, subs, files in os.walk(source):
for fileName in files:
# Do not include any backup files we find
if fileName[-1] == '~' :
continue
if os.path.join(folder, fileName) not in excludeFiles :
if not os.path.isdir(folder.replace(source, target)) :
os.makedirs(folder.replace(source, target))
targetFile = os.path.join(folder, fileName).replace(source, target)
sourceFile = os.path.join(folder, fileName)
if not os.path.isfile(targetFile) :
sys.stdout.write('.')
sys.stdout.flush()
shutil.copy(sourceFile, targetFile)
cn +=1
# Otherwise if the cloud file is older than
# the project file, refresh it
elif self.tools.isOlder(targetFile, sourceFile) :
if os.path.isfile(targetFile) :
os.remove(targetFile)
sys.stdout.write('.')
sys.stdout.flush()
shutil.copy(sourceFile, targetFile)
cr +=1
# Add space for next message
sys.stdout.write('\n')
# Report what happened
self.log.writeToLog(self.errorCodes['4110'])
if cn == 0 and cr == 0 :
self.log.writeToLog(self.errorCodes['4120'])
else :
if cn > 0 :
self.log.writeToLog(self.errorCodes['4130'], [str(cn)])
if cr > 0 :
self.log.writeToLog(self.errorCodes['4140'], [str(cr)])
return True
def getProjHome (self, tPath = None) :
'''Return a project home path by checking to see what the best path
might be. Provided path gets first dibs, then '''
if tPath :
if os.path.isfile(tPath) :
return self.local.projHome
elif self.tools.resolvePath(tPath) :
tPath = self.tools.resolvePath(tPath)
lastFolder = os.path.basename(tPath)
if lastFolder == self.pid :
return tPath
else :
return os.path.join(tPath, self.pid)
else :
self.log.writeToLog(self.errorCodes['4220'], [tPath])
elif self.local.projHome :
return self.local.projHome
else :
return self.tools.resolvePath(os.path.join(self.userConfig['Resources']['projects'], self.pid))
示例2: Usfm
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import isOlder [as 別名]
#.........這裏部分代碼省略.........
# Get some relevant settings
# FIXME: Note page border has not really been implemented yet.
# It is different from backgound management
useIllustrations = self.tools.str2bool(self.projectConfig['Groups'][gid]['useIllustrations'])
useManualAdjustments = self.tools.str2bool(self.projectConfig['Groups'][gid]['useManualAdjustments'])
# See if the working text is present for each subcomponent in the
# component and try to install it if it is not
for cid in cidList :
cType = self.cfg['cType']
cidUsfm = self.getCidPath(cid)
# Test for source here and die if it isn't there
if not os.path.isfile(cidUsfm) :
self.log.writeToLog(self.errorCodes['0220'], [cidUsfm], 'usfm.preProcessGroup():0220')
# Add/manage the dependent files for this cid
# FIXME: Some changes may be needed here to guide creation of adjustment files
# Component adjustment file
cidAdjFile = self.getCidAdjPath(cid)
if useManualAdjustments :
self.createCompAdjustmentFile(cid)
else :
# If no adjustments, remove any exsiting file
if os.path.isfile(cidAdjFile) :
os.remove(cidAdjFile)
# Component piclist file
cidPiclistFile = self.proj_illustration.getCidPiclistFile(cid)
if useIllustrations :
if self.proj_illustration.hasIllustrations(cid) :
# Check for missing illustrations (die here if not found)
if self.proj_illustration.missingIllustrations(cid) :
self.log.writeToLog(self.errorCodes['0300'])
# Create piclist file if not there or if the config has changed
if not os.path.isfile(cidPiclistFile) or self.tools.isOlder(cidPiclistFile, self.local.illustrationConfFile) :
# Now make a fresh version of the piclist file
if self.proj_illustration.createPiclistFile(cid) :
self.log.writeToLog(self.errorCodes['0260'], [cid])
else :
self.log.writeToLog(self.errorCodes['0265'], [cid])
else :
for f in [self.local.layoutConfFile, self.local.illustrationConfFile] :
if self.tools.isOlder(cidPiclistFile, f) or not os.path.isfile(cidPiclistFile) :
# Remake the piclist file
if self.proj_illustration.createPiclistFile(cid) :
self.log.writeToLog(self.errorCodes['0260'], [cid])
else :
self.log.writeToLog(self.errorCodes['0265'], [cid])
else :
# Does not seem to be any illustrations for this cid
# clean out any piclist file that might be there
if os.path.isfile(cidPiclistFile) :
os.remove(cidPiclistFile)
else :
# If we are not using illustrations then any existing piclist file will be removed
if os.path.isfile(cidPiclistFile) :
os.remove(cidPiclistFile)
self.log.writeToLog(self.errorCodes['0255'], [cid])
# Any more stuff to run?
return True
# FIXME: Moved this to xetex.py as that was the only place it was called from
#def checkStartPageNumber (self) :
#'''Adjust page number for the current group. The current logic is
#if there is no number in the startPageNumber setting, we can put