当前位置: 首页>>代码示例>>Python>>正文


Python Tools.removeFile方法代码示例

本文整理汇总了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')
开发者ID:sillsdev,项目名称:rapuma,代码行数:70,代码来源:proj_macro.py

示例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")
开发者ID:jstnlth,项目名称:rapuma,代码行数:70,代码来源:proj_macro.py


注:本文中的rapuma.core.tools.Tools.removeFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。