本文整理匯總了Python中rapuma.core.tools.Tools.writeConfFile方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.writeConfFile方法的具體用法?Python Tools.writeConfFile怎麽用?Python Tools.writeConfFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.writeConfFile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Fixed
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [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'],
}
示例2: ProjScript
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
class ProjScript (object) :
def __init__(self, pid, gid) :
'''Do the primary initialization for this class.'''
self.pid = pid
self.gid = gid
self.tools = Tools()
self.local = ProjLocal(pid)
self.user = UserConfig()
self.userConfig = self.user.userConfig
self.proj_config = Config(pid, gid)
self.proj_config.getProjectConfig()
self.projectConfig = self.proj_config.projectConfig
self.cType = self.projectConfig['Groups'][gid]['cType']
self.Ctype = self.cType.capitalize()
self.log = ProjLog(pid)
# Log messages for this module
self.errorCodes = {
'0000' : ['MSG', 'Placeholder message'],
'1010' : ['MSG', 'Script install process for [<<1>>] Succeeded.'],
'1020' : ['ERR', 'Script install process for [<<1>>] failed.'],
'1030' : ['ERR', 'Script type [<<1>>] not supported.'],
'1040' : ['ERR', 'Script install cannot proceed for [<<1>>] because this script already exists in the project. You must remove it first before you can add another script.'],
'2010' : ['MSG', 'Script remove process for [<<1>>] Succeeded.'],
'2020' : ['ERR', 'Script remove process for [<<1>>] failed.'],
'4210' : ['MSG', 'Processes completed successfully on: [<<1>>] by [<<2>>]'],
'4220' : ['ERR', 'Processes for [<<1>>] failed. Script [<<2>>] returned this error: [<<3>>]'],
'4260' : ['ERR', 'Installed the default component preprocessing script. Editing will be required for it to work with your project.'],
'4265' : ['LOG', 'Component preprocessing script is already installed.'],
'4310' : ['ERR', 'Script is an unrecognized type: [<<1>>] Cannot continue with installation.']
}
###############################################################################
############################# Script Add Functions ############################
###############################################################################
######################## Error Code Block Series = 1000 #######################
###############################################################################
def addScriptFiles (self, path, scriptType) :
'''Import/add processing script files for a group that are found
in the given path. Assumes valid path. Will fail if a copy
doesn't succeed. If the file is already there, give a warning and
will not copy.'''
# import pdb; pdb.set_trace()
source = path
fileName = self.tools.fName(path)
target = os.path.join(self.local.projScriptFolder, fileName)
# Do an initial check to see if the script is already there
# Never copy over the top of an existing script
if os.path.isfile(target) :
self.log.writeToLog(self.errorCodes['1040'], [fileName])
# Make script folder if needed
if not os.path.isdir(self.local.projScriptFolder) :
os.makedirs(self.local.projScriptFolder)
# Copy in the script
if self.scriptInstall(source, target) :
# Record the script file name
if scriptType == 'preprocess' :
self.projectConfig['Groups'][self.gid]['preprocessScript'] = fileName
elif scriptType == 'postprocess' :
self.projectConfig['Groups'][self.gid]['postprocessScript'] = fileName
else :
self.log.writeToLog(self.errorCodes['1030'], [scriptType])
self.tools.writeConfFile(self.projectConfig)
self.log.writeToLog(self.errorCodes['1010'], [fileName])
return True
else :
self.log.writeToLog(self.errorCodes['1020'], [fileName])
###############################################################################
############################ Script Remove Functions ##########################
###############################################################################
######################## Error Code Block Series = 2000 #######################
###############################################################################
def removeScriptFiles (self, scriptType) :
'''Remove processing script files for a group.'''
if scriptType == 'preprocess' :
fileName = self.projectConfig['Groups'][self.gid]['preprocessScript']
elif scriptType == 'postprocess' :
fileName = self.projectConfig['Groups'][self.gid]['postprocessScript']
else :
#.........這裏部分代碼省略.........
示例3: Pdftk
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
###############################################################################
######################## Error Code Block Series = 5000 #######################
###############################################################################
def run (self, gid, cidList, pgRange, override, save) :
'''This will check all the dependencies for a group and then
use pdftk to "render" the whole group or a subset of components
and even a page range in a single component.'''
# import pdb; pdb.set_trace()
# There must be a cidList. If one was not passed, default to
# the group list
cidListSubFileName = ''
saveFile = ''
saveFileName = ''
viewFile = ''
if not cidList :
cidList = self.projectConfig['Groups'][gid]['cidList']
# Make a list of files that pdftk will merge together
sourceList = self.sourceListFromCidList(cidList)
# Merge the files
cmd = ['pdftk'] + sourceList + ['cat', 'output', self.local.gidPdfFile]
# import pdb; pdb.set_trace()
# No return from pdftk is good, we can continue on
if not subprocess.call(cmd) :
# Collect the page count and record in group (Write out at the end of the opp.)
self.projectConfig['Groups'][gid]['totalPages'] = str(PdfFileReader(open(self.local.gidPdfFile)).getNumPages())
# Write out any changes made to the project.conf file that happened during this opp.
self.tools.writeConfFile(self.projectConfig)
# Pull out pages if requested (use the same file for output)
if pgRange :
self.tools.pdftkPullPages(self.local.gidPdfFile, self.local.gidPdfFile, pgRange)
# The gidPdfFile is the residue of the last render and if approved, can be
# used for the binding process. In regard to saving and file naming, the
# gidPdfFile will be copied but never renamed. It must remain intact.
# If the user wants to save this file or use a custom name, do that now
if save and not override :
saveFileName = self.pid + '_' + gid
if cidListSubFileName :
saveFileName = saveFileName + '_' + cidListSubFileName
if pgRange :
saveFileName = saveFileName + '_pg(' + pgRange + ')'
# Add date stamp
saveFileName = saveFileName + '_' + self.tools.ymd()
# Add render file extention
saveFileName = saveFileName + '.pdf'
# Save this to the Deliverable folder (Make sure there is one)
if not os.path.isdir(self.local.projDeliverableFolder) :
os.makedirs(self.local.projDeliverableFolder)
# Final file name and path
saveFile = os.path.join(self.local.projDeliverableFolder, saveFileName)
# Copy, no news is good news
if shutil.copy(self.local.gidPdfFile, saveFile) :
self.log.writeToLog(self.errorCodes['5730'], [saveFileName])
else :
self.log.writeToLog(self.errorCodes['5720'], [saveFileName])
# If given, the override file name becomes the file name
示例4: ProjBackground
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
class ProjBackground (object) :
def __init__(self, pid, gid = None) :
'''Intitate the whole class and create the object.'''
# import pdb; pdb.set_trace()
self.pid = pid
self.gid = gid
self.local = ProjLocal(pid, gid)
self.tools = Tools()
self.proj_config = Config(pid, gid)
self.proj_config.getProjectConfig()
self.proj_config.getLayoutConfig()
self.projectConfig = self.proj_config.projectConfig
self.layoutConfig = self.proj_config.layoutConfig
self.log = ProjLog(pid)
self.user = UserConfig()
self.userConfig = self.user.userConfig
self.projHome = os.path.join(os.environ['RAPUMA_PROJECTS'], self.pid)
self.mmToPx = 72 / 25.4
# For debugging purposes a switch can be set here for verbose
# message output via the terminal
self.debugMode = self.tools.str2bool(self.userConfig['System']['debugging'])
# Log messages for this module
self.errorCodes = {
'0000' : ['MSG', 'Placeholder message'],
'1110' : ['MSG', 'File exsits: [<<1>>]. Use \"force\" to remove it.'],
'1280' : ['ERR', 'Failed to merge background file with command: [<<1>>]. This is the error: [<<2>>]'],
'1290' : ['ERR', 'Failed to convert background file [<<1>>]. Error: [<<2>>] The command was: [<<3>>]'],
'1300' : ['MSG', 'Background merge operation in process, please wait...'],
'1305' : ['MSG', 'Adding document information, please wait...'],
'1310' : ['WRN', 'Failed to add background component: [<<1>>] with error: [<<2>>]'],
'1320' : ['MSG', 'New background created.']
}
###############################################################################
############################### Basic Functions ###############################
###############################################################################
######################## Error Code Block Series = 1000 #######################
###############################################################################
def turnOnBackground (self) :
'''Change the layout config settings to turn on the background.'''
if not self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useBackground']) :
self.layoutConfig['DocumentFeatures']['useBackground'] = True
self.tools.writeConfFile(self.layoutConfig)
def turnOffBackground (self) :
'''Change the layout config settings to turn off the background.'''
if self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useBackground']) :
self.layoutConfig['DocumentFeatures']['useBackground'] = False
self.tools.writeConfFile(self.layoutConfig)
def turnOnDocInfo (self) :
'''Change the layout config settings to turn on the doc info in the background.'''
if not self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useDocInfo']) :
self.layoutConfig['DocumentFeatures']['useDocInfo'] = True
self.tools.writeConfFile(self.layoutConfig)
def turnOffDocInfo (self) :
'''Change the layout config settings to turn off the doc info in the background.'''
if self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useDocInfo']) :
self.layoutConfig['DocumentFeatures']['useDocInfo'] = False
self.tools.writeConfFile(self.layoutConfig)
def addBackground (self, target) :
'''Add a background (watermark) to a rendered PDF file. This will
figure out what the background is to be composed of and create
a master background page. Using force will cause it to be remade.'''
# Do a quick check if the background needs to be remade
# The background normally is not remade if one already exists.
# If one is there, it can be remade if regenerate is set to
# to True. Obviously, if one is not there, it will be made.
if self.tools.str2bool(self.layoutConfig['DocumentFeatures']['regenerateBackground']) :
self.createBackground()
else :
# If there isn't one, make it
if not os.path.exists(self.local.backgroundFile) :
self.createBackground()
# Merge target with the project's background file in the Illustraton folder
self.log.writeToLog(self.errorCodes['1300'])
# Create a special name for the file with the background
# Then merge and save it
viewFile = self.tools.alterFileName(target, 'view')
#.........這裏部分代碼省略.........
示例5: Text
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [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
#.........這裏部分代碼省略.........
示例6: ProjFont
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
# File name less ext is the font ID
parts = len(fileName.split('.'))
return '.'.join(fileName.split('.')[:parts-1])
def getFontIdFromSource (self, source) :
'''Return the font ID based on the complete path and file name.'''
# Get the file name from the path
fileName = self.tools.fName(source)
# Return the font ID
return self.getFontIdFromFileName(fileName)
def recordFont (self, fontId, cType=None) :
'''Check for the exsitance of the specified font in the font folder.
Then extract the meta data into the appropreate configurations.'''
# import pdb; pdb.set_trace()
# Set vars do initial checks
metaDataSource = os.path.join(self.local.projFontFolder, fontId, fontId + '.xml')
if not os.path.isfile(metaDataSource) :
self.log.writeToLog(self.errorCodes['1240'], [fontId + '.xml', 'proj_font.recordFont():1240'])
# Build the Fonts section in the config (if needed)
self.tools.buildConfSection(self.fontConfig, 'Fonts')
# (Re)Inject the font info into the macPack config file.
fInfo = self.tools.getXMLSettings(metaDataSource)
self.fontConfig['Fonts'][fontId] = fInfo.dict()
# Save the settings now
self.tools.writeConfFile(self.fontConfig)
# If a component type was specified, record that as well
if cType :
self.projectConfig['CompTypes'][cType.capitalize()]['fontName'] = fontId
self.tools.writeConfFile(self.projectConfig)
return True
def copyInFont (self, source) :
'''Copy a font into a project. The font is bundled with other
necessary components in a .zip file. If the font folder is
already there we assume there is a font there and we do not
proceed. The user will be prompted to remove the old one first.'''
fontId = self.getFontIdFromSource(source)
confXml = os.path.join(self.local.projFontFolder, fontId, fontId + '.xml')
if not os.path.isfile(source) :
self.log.writeToLog(self.errorCodes['1220'], [source])
# Install new copy
if self.tools.pkgExtract(source, self.local.projFontFolder, confXml) :
self.log.writeToLog(self.errorCodes['1260'], [self.tools.fName(source)])
return True
else :
self.log.writeToLog(self.errorCodes['1265'], [fontId])
return False
def addFont (self, source, cType=None) :
'''It is a three step process to install a font. This will both
copy in a font and record it in one call. Do not try to
示例7: ProjBinding
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
class ProjBinding (object) :
def __init__(self, pid) :
'''Do the primary initialization for this manager.'''
self.pid = pid
self.tools = Tools()
self.user = UserConfig()
self.userConfig = self.user.userConfig
self.config = Config(pid)
self.pg_back = ProjBackground(self.pid)
self.config.getProjectConfig()
self.config.getLayoutConfig()
self.projectConfig = self.config.projectConfig
self.layoutConfig = self.config.layoutConfig
self.useBackground = self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useBackground'])
self.useDocInfo = self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useDocInfo'])
self.projHome = os.path.join(os.environ['RAPUMA_PROJECTS'], self.pid)
self.local = ProjLocal(self.pid)
self.log = ProjLog(self.pid)
self.pdfViewerCmd = self.tools.getPdfViewerCommand(self.userConfig, self.projectConfig)
# Log messages for this module
self.errorCodes = {
'0205' : ['MSG', 'Unassigned message.'],
'0210' : ['MSG', 'No contents are specified for binding.'],
'0215' : ['ERR', 'Failed to bind contents into the [<<1>>] fille. Got error: [<<2>>]'],
'0220' : ['ERR', 'Could not copy [<<1>>] temp file to [<<2>>] saved binding file.'],
'0230' : ['MSG', 'Completed proccessing on the [<<1>>] binding file.'],
'0235' : ['ERR', 'Failed to complete proccessing on the [<<1>>] binding file.'],
'0240' : ['LOG', 'Recorded [<<1>>] rendered pages in the [<<2>>] binding file.'],
'0260' : ['ERR', 'PDF viewer failed with this error: [<<1>>]'],
'0265' : ['ERR', 'Rendered file not found: <<1>>'],
'0270' : ['WRN', 'PDF viewing is disabled.'],
'0280' : ['ERR', 'GS PDF file merge failed with this error: [<<1>>]'],
'0300' : ['MSG', 'File binding operation in process, please wait...']
}
###############################################################################
############################## Binding Functions ##############################
###############################################################################
######################## Error Code Block Series = 200 ########################
###############################################################################
# import pdb; pdb.set_trace()
def bind (self, save = False) :
'''Bind all groups in the order they are indicated by group bindOrder
settings. Note, because binding spans groups and the main body
(project.py) mainly just works on one group at a time, this has to
be called from outside project and project needs to be reinitialized
each time a group is rendered from here.'''
# import pdb; pdb.set_trace()
# Get the order of the groups to be bound.
bindOrder = {}
# Put a safty in here in case there are no groups yet
if not self.projectConfig.has_key('Groups') :
return False
# Build the bindOrder dict with ord num as key and file name as value
for gid in self.projectConfig['Groups'].keys() :
if not self.projectConfig['Groups'][gid].has_key('bindingOrder') :
self.projectConfig['Groups'][gid]['bindingOrder'] = 0
self.tools.writeConfFile(self.projectConfig)
if int(self.projectConfig['Groups'][gid]['bindingOrder']) > 0 :
gidPdfFile = os.path.join(self.local.projComponentFolder, gid, gid + '.pdf')
# bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = self.projectConfig['Groups'][gid]['bindingFile']
bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = gidPdfFile
bindGrpNum = len(bindOrder)
# Need not keep going if nothing was found
if bindGrpNum == 0 :
self.log.writeToLog(self.errorCodes['0210'])
return False
# Make an ordered key list
keyList = bindOrder.keys()
keyList.sort()
# Output the bind files in order according to the list we made
fileList = []
for key in keyList :
fileList.append(bindOrder[key])
# First merge the master pages together
tempFile = self.mergePdfFilesGs(fileList)
# Now add background and doc info if requested
bgFile = ''
if self.useBackground :
bgFile = self.pg_back.addBackground(tempFile)
if self.useDocInfo :
if bgFile :
bgFile = self.pg_back.addDocInfo(bgFile)
else :
bgFile = self.pg_back.addDocInfo(tempFile)
#.........這裏部分代碼省略.........
示例8: ProjDiagnose
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
class ProjDiagnose (object) :
def __init__(self, pid, gid = None) :
'''Intitate the whole class and create the object.'''
# import pdb; pdb.set_trace()
self.pid = pid
self.gid = gid
self.local = ProjLocal(pid, gid)
self.tools = Tools()
self.proj_config = Config(pid, gid)
self.proj_config.getProjectConfig()
self.proj_config.getLayoutConfig()
self.layoutConfig = self.proj_config.layoutConfig
self.user = UserConfig()
self.userConfig = self.user.userConfig
self.log = ProjLog(pid)
# to [px] is 72/25.4
self.mmToPx = 72 / 25.4
# page width [px]
self.paperPxWidth = round(self.mmToPx * float(self.layoutConfig['PageLayout']['pageWidth']),1)
# page height [px]
self.paperPxHeight = round(self.mmToPx * float(self.layoutConfig['PageLayout']['pageHeight']),1)
# Log messages for this module
self.errorCodes = {
'0000' : ['MSG', 'Placeholder message'],
'1310' : ['WRN', 'Failed to add diagnostic component: [<<1>>] with error: [<<2>>]']
}
###############################################################################
############################### Create Functions ##############################
###############################################################################
######################## Error Code Block Series = 1000 #######################
###############################################################################
def turnOnDiagnostic (self) :
'''Change the layout config settings to turn on the diagnostic layer.'''
if not self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useDiagnostic']) :
self.layoutConfig['DocumentFeatures']['useDiagnostic'] = True
self.tools.writeConfFile(self.layoutConfig)
def turnOffDiagnostic (self) :
'''Change the layout config settings to turn off the diagnostic layer.'''
if self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useDiagnostic']) :
self.layoutConfig['DocumentFeatures']['useDiagnostic'] = False
self.tools.writeConfFile(self.layoutConfig)
def addTransparency (self, target, force = False) :
'''Add a transparent layer to a rendered PDF file. This will
add in diagnosing format issues. Using force will cause any
existing layer file to be remade.'''
# Do a quick check if the transparency needs to be remade
# The transparency normally is not remade if one already exists.
# If one is there, it can be remade in two ways, with a force
# or a regenerate command.
if force :
self.createDiagnostic()
elif self.tools.str2bool(self.layoutConfig['DocumentFeatures']['regenerateTransparency']) :
self.createDiagnostic()
else :
# If there isn't one, make it
if not os.path.exists(self.local.diagnosticFile) :
self.createDiagnostic()
# Create a special temp named file for the target
tmpTarget = tempfile.NamedTemporaryFile().name
# Copy the target to the tmpTarget
shutil.copy(target, tmpTarget)
# Overlay the transparency diagnostic file over the tmpTarget
self.tools.mergePdfFilesPdftk(tmpTarget, self.local.diagnosticFile)
# Create a special name for the file with the background
# Then merge and save it
viewFile = self.tools.alterFileName(target, 'view')
# Copy the results back to the target (should be done now)
shutil.copy(tmpTarget, viewFile)
# Not returning a file name would mean it failed
if os.path.exists(viewFile) :
return viewFile
def createDiagnostic (self) :
'''Create a diagnostic transparency (file) that will be
superimposed over the page contents to help diagnose format
issues. This will overwrite any existing transparency file and
will add each recognoized diagnostic type found in the
#.........這裏部分代碼省略.........
示例9: Project
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
module = import_module('rapuma.manager.' + mType)
ManagerClass = getattr(module, mType.capitalize())
manobj = ManagerClass(self, cfg, self.cType)
self.managers[fullName] = manobj
def addManager (self, mType) :
'''Create a manager reference in the project config that components
will point to.'''
# import pdb; pdb.set_trace()
fullName = self.cType + '_' + mType.capitalize()
managerDefaults = None
# Insert the Manager section if it is not already there
self.tools.buildConfSection(self.projectConfig, 'Managers')
if not self.projectConfig['Managers'].has_key(fullName) :
self.tools.buildConfSection(self.projectConfig['Managers'], fullName)
# Update settings if needed
update = False
managerDefaults = self.tools.getXMLSettings(os.path.join(self.local.rapumaConfigFolder, mType + '.xml'))
for k, v, in managerDefaults.iteritems() :
# Do not overwrite if a value is already there
if not self.projectConfig['Managers'][fullName].has_key(k) :
self.projectConfig['Managers'][fullName][k] = v
# If we are dealing with an empty string, don't bother writing out
# Trying to avoid needless conf updating here. Just in case we are
# working with a list, we'll use len()
if len(v) > 0 :
update = True
# Update the conf if one or more settings were changed
if update :
if self.tools.writeConfFile(self.projectConfig) :
self.log.writeToLog(self.errorCodes['0210'],[fullName])
else :
self.log.writeToLog(self.errorCodes['0211'],[fullName])
###############################################################################
############################ Group Level Functions ############################
###############################################################################
####################### Error Code Block Series = 0600 ########################
###############################################################################
def renderGroup (self, cidList = '', pages = '', override = '', save = False) :
'''Render a group of subcomponents or any number of components
in the group specified in the cidList.'''
# import pdb; pdb.set_trace()
# If there are any cids listed we need to test them
if cidList :
self.isValidCidList(cidList)
# Otherwise, do a basic test for exsistance and move on
if self.projectConfig['Groups'].has_key(self.gid) :
# Now create the group and pass the params on
self.createGroup().render(self.gid, cidList, pages, override, save)
return True
def createGroup (self) :
'''Create a group object that can be acted on. It is assumed
this only happens for one group per session. This group
示例10: Usfm
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
#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 createCompAdjustmentFile (self, cid) :
'''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
示例11: UsfmTex
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
on the top margin setting.'''
tm = float(self.layoutConfig['PageLayout']['topMargin'])
hp = float(self.layoutConfig['PageLayout']['headerPosition'])
return float("{0:.2f}".format(round(hp / tm, 2)))
def getFooterPosition (self) :
'''Return the calculated relative position of the footer based
on the bottom margin setting.'''
bm = float(self.layoutConfig['PageLayout']['bottomMargin'])
hp = float(self.layoutConfig['PageLayout']['footerPosition'])
return float("{0:.2f}".format(round(hp / bm, 2)))
def getMarginUnit (self) :
'''Calculate the basic margin unit for the macro package. This will be
based on the largest amount set for the top, bottom and side margins.'''
tm = float(self.layoutConfig['PageLayout']['topMargin'])
bm = float(self.layoutConfig['PageLayout']['bottomMargin'])
im = float(self.layoutConfig['PageLayout']['insideMargin'])
om = float(self.layoutConfig['PageLayout']['outsideMargin'])
# Adjust for binding gutter setting (extra insideMargin)
if self.getBindingGutterWidth() :
im = im - self.getBindingGutterWidth()
return max(float(u) for u in [tm, bm, im, om])
def getTopMarginFactor (self) :
'''Calculate the top margin factor based on what the base margin
and top margin settings are.'''
marginUnit = self.getMarginUnit()
topMargin = float(self.layoutConfig['PageLayout']['topMargin'])
return float("{0:.2f}".format(round(topMargin / marginUnit, 2)))
def getBottomMarginFactor (self) :
'''Calculate the bottom margin factor based on what the base margin
and bottom margin settings are.'''
marginUnit = self.getMarginUnit()
bottomMargin = float(self.layoutConfig['PageLayout']['bottomMargin'])
return float("{0:.2f}".format(round(bottomMargin / marginUnit, 2)))
def getSideMarginFactor (self) :
'''Calculate the side margin factor based on what the base margin
and outside margin settings are.'''
# For this we will be using the outsideMargin setting not the inside
marginUnit = self.getMarginUnit()
outsideMargin = float(self.layoutConfig['PageLayout']['outsideMargin'])
insideMargin = float(self.layoutConfig['PageLayout']['insideMargin'])
self.tools.writeConfFile(self.layoutConfig)
return float("{0:.2f}".format(round(outsideMargin / marginUnit, 2)))
def getBindingGutterWidth (self) :
'''Calculate the binding gutter width based on any extra space added
to the inside margin which exceeds the outside margin.'''
insideMargin = float(self.layoutConfig['PageLayout']['insideMargin'])
outsideMargin = float(self.layoutConfig['PageLayout']['outsideMargin'])
results = insideMargin - outsideMargin
# If nothing, just 0, rather than a float (0.0) so binding gutter
# can be turned off automatically
if int(results) == 0 :
return 0
else :
return results
def getFontSizeUnit (self) :
'''Calculate the font size unit. This counts on the style marker for "p"
being set to 12pt. If for some reason it is not, then this will fail.
This will divide the body font size by 12 to get the size unit.'''
fontDefaultSize = float(self.layoutConfig['TextElements']['fontDefaultSize'])
bodyFontSize = float(self.layoutConfig['TextElements']['bodyFontSize'])
return float("{0:.3f}".format(round(bodyFontSize / fontDefaultSize, 3)))
def getLineSpacingFactor (self) :
'''Calculate the line spacing factor. This is based on the body text leading.
It will divide the body text leading by (leading default size * font size unit)
to get the factor unit. [lsf = btl / (ld x fsu)]'''
fontSizeUnit = self.getFontSizeUnit()
bodyTextLeading = float(self.layoutConfig['TextElements']['bodyTextLeading'])
leadingDefaultSize = float(self.layoutConfig['TextElements']['leadingDefaultSize'])
return float("{0:.3f}".format(round(bodyTextLeading / (leadingDefaultSize * fontSizeUnit), 3)))
示例12: Macro
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
class Macro (object) :
def __init__(self, pid, cType, gid=None) :
'''Do the primary initialization for this class.'''
self.pid = pid
self.gid = gid
self.cType = cType
self.user = UserConfig()
self.userConfig = self.user.userConfig
self.projHome = os.path.join(os.path.expanduser(os.environ['RAPUMA_PROJECTS']), self.pid)
self.local = ProjLocal(pid, gid, cType)
# import pdb; pdb.set_trace()
self.proj_config = Config(pid)
self.proj_config.getProjectConfig()
self.projectConfig = self.proj_config.projectConfig
self.layoutConfig = self.proj_config.layoutConfig
self.tools = Tools()
self.log = ProjLog(pid)
# Create config placeholders
self.layoutConfig = None
self.illustrationConfig = None
self.macroConfig = self.tools.loadConfig(self.local.macroConfFile, self.local.macroConfXmlFile)
# Log messages for this module
self.errorCodes = {
'3010' : ['ERR', 'No macro package is registered for the [<<1>>] component type.'],
'3020' : ['ERR', 'Cannot update! No macro package is registered for the [<<1>>] component type.'],
'3050' : ['ERR', 'Macro package file not found: [<<1>>]'],
'3100' : ['ERR', 'Macro package: [<<1>>] already exists in the project. I am not allowed to copy over an existing package.'],
'3200' : ['ERR', 'Failed to install macro package: [<<1>>]'],
'3300' : ['MSG', 'Installed macro package: [<<1>>], Reinitialized [<<2>>]'],
'3310' : ['ERR', 'Failed to copy [<<1>>] to folder [<<2>>].'],
'3400' : ['MSG', 'Removed macro package configuration settings for: [<<1>>] from the macro.conf file.'],
'3500' : ['MSG', 'Removed macro package [<<1>>] folder and all files contained.'],
'3600' : ['MSG', 'Updated component type [<<1>>] with macro package [<<2>>]'],
'3650' : ['ERR', 'Failed to updated macro package [<<1>>]']
}
###############################################################################
###################### Macro Package Handling Functions #######################
###############################################################################
######################## Error Code Block Series = 3000 #######################
###############################################################################
def createMacroFiles (self, macPackId) :
'''Create all the necessary macro file names with their assigned paths.'''
self.projMacPackFolder = os.path.join(self.local.projMacPackFolder, macPackId)
texFileIds = {'preStyTexExtFile':'preSty-ext.tex', 'macSettingsFile':'settings.tex',
'extTexFile':'extension.tex', 'grpExtTexFile': self.gid + '-extension.tex',
'':'', '':'', '':'', '':'', '':'', }
styFileIds = {'glbExtStyFile':'extension.sty', 'grpExtStyFile': self.gid + '-extension.sty',
'':'', '':'', '':'', '':'', '':''}
def getMacPackIdFromFileName (self, fileName) :
'''Return the macPack ID based on the file name'''
# File name less ext is the ID
parts = len(fileName.split('.'))
return '.'.join(fileName.split('.')[:parts-1])
def getMacPackIdFromSource (self, source) :
'''Return the macPack ID based on the complete path and file name.'''
# Get the file name from the path
fileName = self.tools.fName(source)
# Return the ID
return self.getMacPackIdFromFileName(fileName)
def addMacPack (self, source) :
'''Add a macro package to the project. It will not work if
the same package is already present. Remove must be used
to get rid of the existing one first.'''
# import pdb; pdb.set_trace()
macPackId = self.getMacPackIdFromSource(source)
confXml = os.path.join(self.local.projMacroFolder, macPackId, macPackId + '.xml')
if not os.path.isfile(source) :
self.log.writeToLog(self.errorCodes['3050'], [source])
# Do not add/install if there seems to be a macro package there already
if self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage'] and os.path.exists(self.local.macroConfFile) :
self.log.writeToLog(self.errorCodes['3100'], [macPackId])
return False
# Set the projectConf to the new/same package
self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage'] = macPackId
self.tools.writeConfFile(self.projectConfig)
# If we got this far, install the a fresh copy of the macPack
#.........這裏部分代碼省略.........
示例13: Macro
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
# File name less ext is the ID
parts = len(fileName.split("."))
return ".".join(fileName.split(".")[: parts - 1])
def getMacPackIdFromSource(self, source):
"""Return the macPack ID based on the complete path and file name."""
# Get the file name from the path
fileName = self.tools.fName(source)
# Return the ID
return self.getMacPackIdFromFileName(fileName)
def addMacPack(self, source):
"""Add a macro package to the project. It will not work if
the same package is already present. Remove must be used
to get rid of the existing one first."""
# import pdb; pdb.set_trace()
macPackId = self.getMacPackIdFromSource(source)
confXml = os.path.join(self.local.projMacroFolder, macPackId, macPackId + ".xml")
if not os.path.isfile(source):
self.log.writeToLog(self.errorCodes["3050"], [source])
# Do not add/install if there seems to be a macro package there already
if self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"] and os.path.exists(
self.local.macroConfFile
):
self.log.writeToLog(self.errorCodes["3100"], [macPackId])
return False
# Set the projectConf to the new/same package
self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"] = macPackId
self.tools.writeConfFile(self.projectConfig)
# If we got this far, install the a fresh copy of the macPack
self.installMacPackOnly(source)
# Move the style files and custom TeX files out of the macPack
self.moveMacStyles(macPackId)
self.moveMacTex(macPackId)
# Create a fresh macro.conf file if it dosn't exist
if not os.path.isfile(self.local.macroConfFile):
self.macroConfig = self.tools.initNewConfig(self.local.macroConfFile, self.local.macroConfXmlFile)
# Inject information from this particular macro package
mInfo = self.tools.getXMLSettings(confXml)
self.macroConfig["Macros"][macPackId] = mInfo.dict()
# Save the settings now
self.tools.writeConfFile(self.macroConfig)
self.log.writeToLog(self.errorCodes["3300"], [macPackId, self.local.macroConfFileName])
return True
def moveMacStyles(self, macPackId):
"""Move the default macro package styles out of the freshly installed
project macro package folder to the project Style folder."""
# import pdb; pdb.set_trace()
# Collect the style files to copy
for f in self.getMacStyExtFiles(macPackId):
source = os.path.join(os.path.join(self.local.projMacroFolder, macPackId, f))
target = os.path.join(self.local.projStyleFolder, f)
self.tools.makedirs(self.local.projStyleFolder)
示例14: ProjBinding
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
class ProjBinding (object) :
def __init__(self, pid) :
'''Do the primary initialization for this manager.'''
self.pid = pid
self.tools = Tools()
self.user = UserConfig()
self.userConfig = self.user.userConfig
self.config = Config(pid)
self.pg_back = ProjBackground(self.pid)
self.config.getProjectConfig()
self.config.getLayoutConfig()
self.projectConfig = self.config.projectConfig
self.layoutConfig = self.config.layoutConfig
self.useBackground = self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useBackground'])
self.useDocInfo = self.tools.str2bool(self.layoutConfig['DocumentFeatures']['useDocInfo'])
self.projHome = os.path.join(self.userConfig['Resources']['projects'], self.pid)
self.local = ProjLocal(self.pid)
self.log = ProjLog(self.pid)
self.pdfViewerCmd = self.userConfig['System']['pdfViewerCommand']
# Log messages for this module
self.errorCodes = {
'0205' : ['MSG', 'Unassigned message.'],
'0210' : ['MSG', 'No contents are specified for binding.'],
'0215' : ['ERR', 'Failed to bind contents into the [<<1>>] fille. Got error: [<<2>>]'],
'0220' : ['ERR', 'Could not copy [<<1>>] temp file to [<<2>>] saved binding file.'],
'0230' : ['MSG', 'Completed proccessing on the [<<1>>] binding file.'],
'0235' : ['ERR', 'Failed to complete proccessing on the [<<1>>] binding file.'],
'0240' : ['LOG', 'Recorded [<<1>>] rendered pages in the [<<2>>] binding file.'],
'0260' : ['ERR', 'PDF viewer failed with this error: [<<1>>]'],
'0265' : ['ERR', 'Rendered file not found: <<1>>'],
'0270' : ['WRN', 'PDF viewing is disabled.'],
'0280' : ['ERR', 'GS PDF file merge failed with this error: [<<1>>]'],
'0300' : ['MSG', 'File binding operation in process, please wait...']
}
###############################################################################
############################## Binding Functions ##############################
###############################################################################
######################## Error Code Block Series = 200 ########################
###############################################################################
# import pdb; pdb.set_trace()
def bind (self, save = False) :
'''Bind all groups in the order they are indicated by group bindOrder
settings. Note, because binding spans groups and the main body
(project.py) mainly just works on one group at a time, this has to
be called from outside project and project needs to be reinitialized
each time a group is rendered from here.'''
# import pdb; pdb.set_trace()
# Get the order of the groups to be bound.
bindOrder = {}
# Put a safty in here in case there are no groups yet
if not self.projectConfig.has_key('Groups') :
return False
# Build the bindOrder dict with ord num as key and file name as value
for gid in self.projectConfig['Groups'].keys() :
if not self.projectConfig['Groups'][gid].has_key('bindingOrder') :
self.projectConfig['Groups'][gid]['bindingOrder'] = 0
self.tools.writeConfFile(self.projectConfig)
if int(self.projectConfig['Groups'][gid]['bindingOrder']) > 0 :
gidPdfFile = os.path.join(self.local.projComponentFolder, gid, gid + '.pdf')
# bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = self.projectConfig['Groups'][gid]['bindingFile']
bindOrder[self.projectConfig['Groups'][gid]['bindingOrder']] = gidPdfFile
bindGrpNum = len(bindOrder)
# Need not keep going if nothing was found
if bindGrpNum == 0 :
self.log.writeToLog(self.errorCodes['0210'])
return False
# Make an ordered key list
keyList = bindOrder.keys()
keyList.sort()
# Output the bind files in order according to the list we made
fileList = []
for key in keyList :
fileList.append(bindOrder[key])
# First merge the master pages together
tempFile = self.mergePdfFilesGs(fileList)
# Now add background and doc info if requested
bgFile = ''
if self.useBackground :
bgFile = self.pg_back.addBackground(tempFile)
if self.useDocInfo :
if bgFile :
bgFile = self.pg_back.addDocInfo(bgFile)
else :
#.........這裏部分代碼省略.........
示例15: Xetex
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import writeConfFile [as 別名]
#.........這裏部分代碼省略.........
'1000' : ['WRN', 'XeTeX debugging is set to [<<1>>]. These are the paths XeTeX is seeing: [<<2>>]'],
'1090' : ['ERR', 'Invalid value [<<1>>] used for XeTeX debugging. Must use an integer of 0, 1, 2, 4, 8, 16, or 32']
}
# FIXME: It would be good if we could do a check for dependent files here
###############################################################################
############################ Manager Level Functions ##########################
###############################################################################
######################## Error Code Block Series = 1000 #######################
###############################################################################
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
one in there as a suggestion. If there is already one there, the
user will be responsible for seeing that it is correct.'''
# import pdb; pdb.set_trace()
try :
# Simply try to return anything that is in the field
cStrPgNo = self.projectConfig['Groups'][self.gid]['startPageNumber']
if cStrPgNo != '' :
return cStrPgNo
except :
# 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