本文整理匯總了Python中rapuma.core.tools.Tools.initNewConfig方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.initNewConfig方法的具體用法?Python Tools.initNewConfig怎麽用?Python Tools.initNewConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.initNewConfig方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Macro
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import initNewConfig [as 別名]
#.........這裏部分代碼省略.........
# 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)
# Do not overwrite existing files unless force is used
if not os.path.exists(target) :
shutil.copy(source, target)
# Look for default and set to read-only
defaultStyFile = os.path.join(self.local.projStyleFolder, macPackId + '.sty')
if target == defaultStyFile :
self.tools.makeReadOnly(defaultStyFile)
# Remove the source to avoid confusion
示例2: Macro
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import initNewConfig [as 別名]
#.........這裏部分代碼省略.........
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)
# Do not overwrite existing files unless force is used
if not os.path.exists(target):
shutil.copy(source, target)
# Look for default and set to read-only
defaultStyFile = os.path.join(self.local.projStyleFolder, macPackId + ".sty")
if target == defaultStyFile:
self.tools.makeReadOnly(defaultStyFile)
# Remove the source to avoid confusion
if os.path.exists(target):
os.remove(source)