本文整理汇总了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)
#.........这里部分代码省略.........