本文整理匯總了Python中rapuma.core.tools.Tools.removeFile方法的典型用法代碼示例。如果您正苦於以下問題:Python Tools.removeFile方法的具體用法?Python Tools.removeFile怎麽用?Python Tools.removeFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rapuma.core.tools.Tools
的用法示例。
在下文中一共展示了Tools.removeFile方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Macro
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import removeFile [as 別名]
#.........這裏部分代碼省略.........
tFiles.append(f)
return tFiles
def removeMacPack (self) :
'''Remove the macro package from a component type'''
# import pdb; pdb.set_trace()
if self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage'] != '' :
macPackId = self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage']
else :
self.log.writeToLog(self.errorCodes['3010'], [self.cType])
# Aquire target to delete
target = os.path.join(self.local.projMacroFolder, macPackId)
# Remove the macPack settings from the config file if it is there
try :
del self.macroConfig['Macros'][macPackId]
# Save the settings now
self.tools.writeConfFile(self.macroConfig)
self.log.writeToLog(self.errorCodes['3400'], [macPackId])
except :
pass
# Now remove the macro folder (with all its contents)
if os.path.exists(target) :
shutil.rmtree(target)
self.log.writeToLog(self.errorCodes['3500'], [macPackId])
# Remove any style files associated with the macro
styTarget = os.path.join(self.local.projStyleFolder, macPackId + '.sty')
self.tools.makeExecutable(styTarget)
self.tools.removeFile(styTarget)
# Remove the reference for this macro package from the component type
# that uses it. Normally that would probably be just be one of them.
self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage'] = ''
self.tools.writeConfFile(self.projectConfig)
def updateMacPack (self, source) :
'''Update a macro package with the latest version but do not
touch the config file.'''
# Do not update if no macro package is registered in the projectConfig
if not self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage'] :
self.log.writeToLog(self.errorCodes['3020'], [self.cType.capitalize()])
return False
macPackId = self.getMacPackIdFromSource(source)
confXml = os.path.join(self.local.projMacroFolder, macPackId, macPackId + '.xml')
oldMacPackId = self.projectConfig['CompTypes'][self.cType.capitalize()]['macroPackage']
oldMacDir = os.path.join(self.local.projMacroFolder, oldMacPackId)
newMacDir = os.path.join(self.local.projMacroFolder, macPackId)
# Install the new macPack (but use the old settings)
if self.installMacPackOnly(source) :
# The current macro system must have a "master" style file.
# This is a version of the ParaText style file. Because
# an update might include an update to the style file,
# we need to copy that from the macro folder to the Style
# folder. We will do that now. The name of the file should
# be the macPackId + ".sty", in theory.
srcStyleFile = os.path.join(self.local.projMacroFolder, macPackId, macPackId + '.sty')
示例2: Macro
# 需要導入模塊: from rapuma.core.tools import Tools [as 別名]
# 或者: from rapuma.core.tools.Tools import removeFile [as 別名]
#.........這裏部分代碼省略.........
if f.find("ext.tex") > 0:
tFiles.append(f)
return tFiles
def removeMacPack(self):
"""Remove the macro package from a component type"""
# import pdb; pdb.set_trace()
if self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"] != "":
macPackId = self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"]
else:
self.log.writeToLog(self.errorCodes["3010"], [self.cType])
# Aquire target to delete
target = os.path.join(self.local.projMacroFolder, macPackId)
# Remove the macPack settings from the config file if it is there
try:
del self.macroConfig["Macros"][macPackId]
# Save the settings now
self.tools.writeConfFile(self.macroConfig)
self.log.writeToLog(self.errorCodes["3400"], [macPackId])
except:
pass
# Now remove the macro folder (with all its contents)
if os.path.exists(target):
shutil.rmtree(target)
self.log.writeToLog(self.errorCodes["3500"], [macPackId])
# Remove any style files associated with the macro
styTarget = os.path.join(self.local.projStyleFolder, macPackId + ".sty")
self.tools.makeExecutable(styTarget)
self.tools.removeFile(styTarget)
# Remove the reference for this macro package from the component type
# that uses it. Normally that would probably be just be one of them.
self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"] = ""
self.tools.writeConfFile(self.projectConfig)
def updateMacPack(self, source):
"""Update a macro package with the latest version but do not
touch the config file."""
# Do not update if no macro package is registered in the projectConfig
if not self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"]:
self.log.writeToLog(self.errorCodes["3020"], [self.cType.capitalize()])
return False
macPackId = self.getMacPackIdFromSource(source)
confXml = os.path.join(self.local.projMacroFolder, macPackId, macPackId + ".xml")
oldMacPackId = self.projectConfig["CompTypes"][self.cType.capitalize()]["macroPackage"]
oldMacDir = os.path.join(self.local.projMacroFolder, oldMacPackId)
newMacDir = os.path.join(self.local.projMacroFolder, macPackId)
# Install the new macPack (but use the old settings)
if self.installMacPackOnly(source):
# The current macro system must have a "master" style file.
# This is a version of the ParaText style file. Because
# an update might include an update to the style file,
# we need to copy that from the macro folder to the Style
# folder. We will do that now. The name of the file should
# be the macPackId + ".sty", in theory.
srcStyleFile = os.path.join(self.local.projMacroFolder, macPackId, macPackId + ".sty")
oldStyleFile = os.path.join(self.local.projStyleFolder, oldMacPackId + ".sty")
newStyleFile = os.path.join(self.local.projStyleFolder, macPackId + ".sty")