diff --git a/src/eoatex2imxml.py b/src/eoatex2imxml.py index e7603b1..2c8874b 100755 --- a/src/eoatex2imxml.py +++ b/src/eoatex2imxml.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2019-12-18 11:16:11 (kthoden)> +# Time-stamp: <2020-03-04 11:54:38 (kthoden)> """ Converts Latex files into a customized DocBook XML file. @@ -351,20 +351,6 @@ def pdf_burst(input_file, tmpDir): pageno += 1 # def pdf_burst ends here -def progress(count, total, status=''): - """Progress bar for command line. Taken from - https://gist.github.com/vladignatyev/06860ec2040cb497f0f3""" - - bar_len = 60 - filled_len = int(round(bar_len * count / float(total))) - - percents = round(100.0 * count / float(total), 1) - bar = '#' * filled_len + '-' * (bar_len - filled_len) - - sys.stdout.write('[%s] %s%s ... %s\r' % (bar, percents, '%', status)) - sys.stdout.flush() -# def progress ends here - def cleanup(): """Remove support files""" try: @@ -762,7 +748,7 @@ def process_inline_equations( xmlChapters ): else: strSourceCode = xmlEOAineq.text - progress(intEOAineqnumber, len(xmlEOAineqs),"Processing EOAineq %s of %s." % (intEOAineqnumber, len(xmlEOAineqs))) + libeoaconvert.progress(intEOAineqnumber, len(xmlEOAineqs),"Processing EOAineq %s of %s." % (intEOAineqnumber, len(xmlEOAineqs))) strSourceCode = os.linesep.join([s for s in strSourceCode.splitlines() if s]) @@ -823,7 +809,7 @@ def process_inline_equations( xmlChapters ): counter_dictEOAineqs = 1 for intRunningOrder in dictEOAineqs.keys(): # provide more status information here in output! - progress(counter_dictEOAineqs, len(dictEOAineqs.keys()),"Splitting all inline equations, image %s of %s" % (counter_dictEOAineqs, len(dictEOAineqs.keys()))) + libeoaconvert.progress(counter_dictEOAineqs, len(dictEOAineqs.keys()),"Splitting all inline equations, image %s of %s" % (counter_dictEOAineqs, len(dictEOAineqs.keys()))) Kommando = "{cmd} {arg1} {arg2}".format( cmd = PDFCROP_EXEC, arg1 = (formula_tmp_dir / ("EOAformulas_" + str(intRunningOrder) + ".pdf")).absolute(), @@ -863,7 +849,7 @@ def process_eoachem( xmlChapters ): str_chem_text = xml_EOAchem.text - progress(int_EOAchem_number, len(xmlEOAchems),"Processing EOAchem %s of %s." % (int_EOAchem_number, len(xmlEOAchems))) + libeoaconvert.progress(int_EOAchem_number, len(xmlEOAchems),"Processing EOAchem %s of %s." % (int_EOAchem_number, len(xmlEOAchems))) str_chem_text = os.linesep.join([s for s in str_chem_text.splitlines() if s]) str_tex_chem = str_tex_chem + "\ce{" + str_chem_text + "}\n\\newpage\n" @@ -909,7 +895,7 @@ def process_eoachem( xmlChapters ): counter_dictEOAchems = 1 for intRunningOrder in dictEOAchems.keys(): # provide more status information here in output! - progress(counter_dictEOAchems, len(dictEOAchems.keys()),"Splitting all inline equations, image %s of %s" % (counter_dictEOAchems, len(dictEOAchems.keys()))) + libeoaconvert.progress(counter_dictEOAchems, len(dictEOAchems.keys()),"Splitting all inline equations, image %s of %s" % (counter_dictEOAchems, len(dictEOAchems.keys()))) Kommando = "{cmd} {arg1} {arg2}".format( cmd=PDFCROP_EXEC, arg1=(formula_tmp_dir / ("EOAformulas_" + str(intRunningOrder) + ".pdf")).absolute(), @@ -1511,7 +1497,7 @@ def add_bibliography_to_xml( for xmlCitation in xmlCitations: string_citekey = xmlCitation.find("./citekey").text - progress(counter_citations, len(xmlCitations),"Processing reference %s of %s: %s" % (counter_citations, len(xmlCitations), string_citekey)) + libeoaconvert.progress(counter_citations, len(xmlCitations),"Processing reference %s of %s: %s" % (counter_citations, len(xmlCitations), string_citekey)) # If Bibliography-Type is anthology find Refsection for this Chapter ############### # old version # diff --git a/src/utils/libeoaconvert.py b/src/utils/libeoaconvert.py index 2a75bc0..0ed86bc 100644 --- a/src/utils/libeoaconvert.py +++ b/src/utils/libeoaconvert.py @@ -545,3 +545,18 @@ def has_text_or_children(cr): htoc = False return htoc # def has_text_or_children ends here + + +def progress(count, total, status=''): + """Progress bar for command line. Taken from + https://gist.github.com/vladignatyev/06860ec2040cb497f0f3""" + + bar_len = 60 + filled_len = int(round(bar_len * count / float(total))) + + percents = round(100.0 * count / float(total), 1) + bar = '#' * filled_len + '-' * (bar_len - filled_len) + + sys.stdout.write('[%s] %s%s ... %s\r' % (bar, percents, '%', status)) + sys.stdout.flush() +# def progress ends here