本文整理匯總了Python中rapuma.core.tools.Tools.makeFileHeader方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.makeFileHeader方法的具體用法?Python Tools.makeFileHeader怎麽用?Python Tools.makeFileHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.makeFileHeader方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Xetex
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import makeFileHeader [as 別名]
#.........這裏部分代碼省略.........
# If nothing is there, we'll make a suggestion
pGrp = str(self.projectConfig['Groups'][self.gid]['precedingGroup'])
if pGrp == 'None' :
self.projectConfig['Groups'][self.gid]['startPageNumber'] = 1
self.tools.writeConfFile(self.projectConfig)
return '1'
else :
# Calculate the suggested number based on the preceeding group
try :
cStrPgNo = str(self.projectConfig['Groups'][self.gid]['startPageNumber'])
except :
cStrPgNo = 1
self.projectConfig['Groups'][self.gid]['startPageNumber'] = 1
try :
pGrpPgs = int(self.projectConfig['Groups'][pGrp]['totalPages'])
pGrpStrPgNo = int(self.projectConfig['Groups'][pGrp]['startPageNumber'])
except :
# FIXME: Maybe this could go out and find out exactly how many pages were in the preceeding group
pGrpPgs = 1
pGrpStrPgNo = 1
self.projectConfig['Groups'][pGrp]['totalPages'] = 1
self.projectConfig['Groups'][pGrp]['startPageNumber'] = 1
# Whether this is right or wrong set it the way it is
self.projectConfig['Groups'][self.gid]['startPageNumber'] = (pGrpStrPgNo + pGrpPgs)
self.tools.writeConfFile(self.projectConfig)
return self.projectConfig['Groups'][pGrp]['startPageNumber']
def makeExtFile (self, fileName, description) :
'''Generic function to create an extension file if one does not already exist.'''
if not os.path.exists(fileName) :
with codecs.open(fileName, "w", encoding='utf_8') as writeObject :
writeObject.write(self.tools.makeFileHeader(fileName, description, False))
self.log.writeToLog(self.errorCodes['1040'], [self.tools.fName(fileName)])
return True
def makeCmpExtTexFileOn (self, fileName) :
'''Create a component TeX extention macro "on" file for a specified component. A matching "off"
file will be created as well.'''
description = 'This is a component (on) TeX macro extension file which may override any macros \
which were loaded for this rendering process. This file is read just before the component \
working file. After the component is rendered, the accompanying off TeX file will be \
loaded which will turn off any modified macro commands that this TeX file has set. The \
user must edit this file in order for it to work right.'
return self.makeExtFile(fileName, description)
def makeCmpExtTexFileOff (self, fileName) :
'''Create a component TeX extention macro "off" file for a specified component. This is to
match the "on" file that was created.'''
description = 'This is a component (off) style extension file which overrides the settings \
that were loaded for this rendering process just prior to loading the component working \
file. The commands in this style file will off-set the "on" settings causing the macro to \
render as it did before the "on" styles were loaded. The user must edit this file for it \
to work properly.'
return self.makeExtFile(fileName, description)
def makeCmpExtStyFileOn (self, fileName) :
'''Create a component style extentions "on" file for a specified component. A matching "off"
示例2: Usfm
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import makeFileHeader [as 別名]
#.........這裏部分代碼省略.........
'''Create an adjustment file for this cid. If entries exsist in
the adjustment.conf file.'''
description = 'Auto-generated text adjustments file for: ' + cid + '\n'
# import pdb; pdb.set_trace()
# Check for a master adj conf file
if os.path.exists(self.local.adjustmentConfFile) :
adjFile = self.getCidAdjPath(cid)
# Clean up old file if there is one so we can start fresh
if os.path.exists(adjFile) :
os.remove(adjFile)
# Nothing to do if no gid section is found
if not self.adjustmentConfig.has_key(self.gid) :
self.tools.buildConfSection(self.adjustmentConfig, self.gid)
if not self.adjustmentConfig[self.gid].has_key(cid) :
self.tools.buildConfSection(self.adjustmentConfig[self.gid], cid)
self.adjustmentConfig[self.gid][cid]['%1.1'] = '1'
self.tools.writeConfFile(self.adjustmentConfig)
self.log.writeToLog(self.errorCodes['0240'], [cid])
return False
# Sort through commented adjustment lines ()
if self.adjustmentConfig[self.gid].has_key(cid) :
c = False
for k in self.adjustmentConfig[self.gid][cid].keys() :
if not re.search(r'%|#', k) :
c = True
if not c :
self.log.writeToLog(self.errorCodes['0245'], [cid])
return False
# If we make it this far, create the new adjustment file
with codecs.open(adjFile, "w", encoding='utf_8') as writeObject :
writeObject.write(self.tools.makeFileHeader(adjFile, description, True))
# Output like this: JAS 1.13 +1
for k, v in self.adjustmentConfig[self.gid][cid].iteritems() :
if re.search(r'%|#', k) :
continue
adj = v
if int(v) > 0 :
adj = '+' + str(v)
writeObject.write(cid.upper() + ' ' + k + ' ' + adj + '\n')
self.log.writeToLog(self.errorCodes['0230'], [self.tools.fName(adjFile)])
return True
def createProjAdjustmentConfFile (self) :
'''Create a project master component adjustment file that group component
ajustment files will be created automatically from. This will run every
time preprocess is run but after the first time it will only add a sections
for new groups or components.'''
if not os.path.exists(self.adjustmentConfFile) :
self.adjustmentConfig = ConfigObj(self.adjustmentConfFile, encoding='utf-8')
self.adjustmentConfig.filename = self.adjustmentConfFile
self.updateCompAdjustmentConf()
return True
def updateCompAdjustmentConf (self) :
'''Update an adjustmentConfig based on changes in the projectConfig.'''
for gid in self.projectConfig['Groups'].keys() :
if gid not in self.adjustmentConfig.keys() :