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


Python Executor.finished方法代码示例

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


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

示例1: __init__

# 需要导入模块: from executor import Executor [as 别名]
# 或者: from executor.Executor import finished [as 别名]
class Reactor:
    def __init__(
        self, rule_file_path, config_file_path, site_config, in_folder_path, out_folder_path, shared_dir, log_file
    ):
        self.rule_file_path = rule_file_path + "/reactor_rules.rrule"
        self.config_file_path = config_file_path + "/reactor_config.config"
        config_dir_path = site_config[: site_config.rfind("/")]
        self.in_folder_path = in_folder_path
        self.out_folder_path = out_folder_path
        self.shared_dir = shared_dir
        self.rule_list = []
        self.log_file = log_file
        self.buildRules()
        self.executor = Executor(config_dir_path)
        self.count = 0
        self.INVALID_TAGS = ["table", "tbody", "tr", "td"]
        self.full_update = os.getenv("REACTOR_UPDATE_ALL") == "YES"
        self.update_set = None

    def __str__(self):
        return 'Reactoring files in folder "' + self.in_folder_path + '" to folder "' + self.out_folder_path

    def buildRules(self):
        parser = RuleParser()
        self.rule_list = parser.parseFile(self.rule_file_path)

    def doReactorWork(self):
        if not self.ensureInputFolderExists():
            print "Error: Input folder does not exists."
            return

        self.ensureOutputFolderExists()

        if not self.full_update:
            self.genUpdateList()

        print "Generating navigation files..."
        self.genNavFiles()

        print "Begin processing..."
        self.processFilesRecursively(self.doWork)

        self.executor.finished()

        print "Done!"
        return

    def ensureInputFolderExists(self):
        return os.path.exists(self.in_folder_path)

        # 确认输出目录是否存在,如果不存在,就创建这个目录

    def ensureOutputFolderExists(self):
        if not os.path.exists(self.out_folder_path):
            os.makedirs(self.out_folder_path)

    def genUpdateList(self):
        update_list_path = self.shared_dir + "/updatelist.dat"
        update_list = [line.strip() for line in open(update_list_path)]
        self.update_set = Set(update_list)

        # 生成index.xml,l、c目录下的xml

    def genNavFiles(self):
        indexPath = self.shared_dir + "/dir.xml"

        if len(indexPath) > 0:
            homePath = os.getenv("HOME")
            command = "%s/labrador/butts/reactor/producer --index-file=%s --webroot-dir=%s --log-file=%s" % (
                homePath,
                indexPath,
                self.out_folder_path,
                self.log_file,
            )
            os.system(command)
        else:
            print "Index file not found!"

    def getDataFilePathForFileName(self, fileName):
        return self.in_folder_path + "/" + fileName[:2] + "/" + fileName

    def dataFileExists(self, fileName, filePath):
        return (filePath.find("/a/") != -1) and os.path.exists(self.getDataFilePathForFileName(fileName))

    def integrateParentWithData(self, fileName, parentFile):
        dataFile = self.getDataFilePathForFileName(fileName)
        data = codecs.open(dataFile, "r", "utf-8")
        dataContent = data.read()
        data.close()

        dataContent = html.unescape_string(dataContent)
        # get rid of something like " "
        #   =>   => " "
        dataContent = html.unescape_string(dataContent)
        dataContent = dataContent.replace("<o:p>", "<p>").replace("</o:p>", "</p>")
        # dataContent = dataContent.replace("<st1:", "<!--<st1:").replace("st1:chsdate>", "st1:chsdate>-->").replace("st1:chmetcnv>", "st1:chmetcnv>-->").replace("st1:personname>", "st1:personname>-->")
        # 20130327 fix#374
        str_result = dataContent
        r = re.compile("xml:namespace prefix = (.*?) ns")
        s_match = r.findall(str_result)
#.........这里部分代码省略.........
开发者ID:hrbesd,项目名称:labrador,代码行数:103,代码来源:reactor_main.py


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