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


Python FileSystem.fileGetContents方法代码示例

本文整理汇总了Python中FileSystem.FileSystem.fileGetContents方法的典型用法代码示例。如果您正苦于以下问题:Python FileSystem.fileGetContents方法的具体用法?Python FileSystem.fileGetContents怎么用?Python FileSystem.fileGetContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem.FileSystem的用法示例。


在下文中一共展示了FileSystem.fileGetContents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: merge

# 需要导入模块: from FileSystem import FileSystem [as 别名]
# 或者: from FileSystem.FileSystem import fileGetContents [as 别名]
def merge(newConfigPath, oldConfigPath, destinationConfigPath, rulesPythonScript, isLogging, logDir, errorReporting, writeBackup):
    #register rules
    MergeRuleFactory.initialise()
    MergeRuleFactory.registerRule("CopyValue", MergeRuleSingleShot)
    MergeRuleFactory.registerRule("DeleteSection", MergeRuleDeleteNode)
    MergeRuleFactory.registerRule("CopySection", MergeRuleSectionIntelligence)

    #register XmlMerger
    merger = XmlMerger()

    if merger.initErrorReporting(errorReporting) is False:
        print "Can`t init error reporting"
        return False
        pass

    if isLogging is True:
        if logDir is None:
            logDir = FileSystem.getCurrentDirectory()
            pass

        if FileSystem.isDirectory(logDir) is False:
            ErrorHandler.error("Directory for logs not exist %s " % logDir)
            return False
            pass

        if merger.initLogging(logDir) is False:
            ErrorHandler.error("can `t init Logger  ")
            return False
            pass
        
    if merger.initialise(newConfigPath, oldConfigPath) is False:
        ErrorHandler.error("can `t initialise")
        return False
        pass

    #add actions
    #BE CAREFUL TUPLE WITH ONE ELEMENT = (element,)  not (element) because in that case we shall have sequence (e,l,e,m,e,n,t) :-)
    #merger.addAction( "SingleShot", GraphQuery(("general","systemtotaluptime")) )
    #merger.addAction( "SectionIntelligence", GraphQuery(("myvideos",)) )
    #merger.addAction( "SectionIntelligence", GraphQuery(("mymusic",)), BlackList = ["scanning"] )
    #merger.addAction( "SectionIntelligence", GraphQuery(("viewstates",)) )
    content = FileSystem.fileGetContents(rulesPythonScript)

    execfile( rulesPythonScript, dict(merger = merger
                                      , GraphQuery = GraphQuery
                                      , QUERY_POLICY_ONLY_NEW = QUERY_POLICY_ONLY_NEW
                                      , QUERY_POLICY_BOTH = QUERY_POLICY_BOTH) )
    merger.merge()

    if writeBackup is True:
        backupPath = FileSystem.setFileExtension(oldConfigPath,"bak.xml")
        FileSystem.copyFile(oldConfigPath, backupPath)
        pass
    
    if merger.save(destinationConfigPath) is False:
        ErrorHandler.error("Error saving result %s. Please check  directory write permissions." % destinationConfigPath)
        return False
        pass

    return True
    pass
开发者ID:gloryofrobots,项目名称:XBMCConfigMerge,代码行数:63,代码来源:Merge.py


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