def replace_xml_files(xmls_with_path, words, progress_bar=None, status_bar=None, meanings=None):
global current_progress_in_percent
xml_file_count = len(xmls_with_path)
files_processed = 0
for xml in xmls_with_path:
# content = open(xml).read()
# print("Processing: " + xml)
xml_file_contents = read_contents(xml)
# print(xml_file_contents)
for i in range(0, len(words)):
word = words[i]
# print(word)
if meanings:
meaning = meanings[i]
xml_file_contents = highlight_content(
xml_file_contents, word, meaning)
else:
xml_file_contents = highlight_content(
xml_file_contents, word)
# print(xml_file_contents)
write_content(xml, xml_file_contents)
files_processed = files_processed + 1
current_progress_in_percent = (files_processed / xml_file_count)
msg = "processing " + os.path.basename(xml)
if status_bar and progress_bar:
status_bar.push(1, msg)
progress_bar.set_fraction(current_progress_in_percent)
while Gtk.events_pending():
Gtk.main_iteration()
# do_something_with_progress(current_progress_in_percent)
评论列表
文章目录