version__ = lyx2lyx_version.version
stable_version = True
-except: # we are running from build directory so assume the last version
+except ModuleNotFoundError:
+ # we are running from the build directory so assume the last version
version__ = "2.5"
stable_version = False
gzip.open(input).readline()
self.input = gzip.open(input)
self.compressed = True
- except:
+ except OSError:
self.input = open(input, "rb")
self.compressed = False
else:
init_t = time.time()
try:
conv(self)
- except:
+ except Exception as exception:
self.warning(
- "An error occurred in %s, %s" % (version, str(conv)),
+ f"An error occurred in {version}, {conv}",
default_debug__,
)
if not self.try_hard:
- raise
+ raise exception
self.status = 2
else:
self.warning(
- "%lf: Elapsed time on %s" % (time.time() - init_t, str(conv)),
+ f"{time.time() - init_t:f}: Elapsed time on {conv}",
default_debug__ + 1,
)
self.format = version
if last_step[1][-1] == self.end_format:
steps.pop()
- self.warning("Convertion mode: %s\tsteps%s" % (mode, steps), 10)
+ self.warning(f"Convertion mode: {mode}\tsteps{steps}", 10)
return mode, steps
def append_local_layout(self, new_layout):
" Program used to convert between different versions of the lyx file format."
import argparse
import sys
+
import LyX
"Malformed LyX document: 'has_inner_box' or "
"'use_makebox' option not found in box inset!"
)
- ertinset = put_cmd_in_ert("\\fcolorbox{%s}{%s}{" % (framecolor, backcolor))
+ ertinset = put_cmd_in_ert(f"\\fcolorbox{{{framecolor}}}{{{backcolor}}}{{")
else:
ertinset = put_cmd_in_ert("\\colorbox{%s}{" % backcolor)
document.body[i:i] = ertinset + [""]
add_to_preamble(document, "\\theoremstyle{definition}")
if is_starred or mod == "theorems-bytype" or mod == "theorems-ams-bytype":
add_to_preamble(
- document, "\\%s{%s}{\\protect\\solutionname}" % (theoremName, LaTeXName)
+ document, f"\\{theoremName}{{{LaTeXName}}}{{\\protect\\solutionname}}"
)
else: # mod == "theorems-std" or mod == "theorems-ams" and not is_starred
add_to_preamble(
document,
- "\\%s{%s}[thm]{\\protect\\solutionname}" % (theoremName, LaTeXName),
+ f"\\{theoremName}{{{LaTeXName}}}[thm]{{\\protect\\solutionname}}",
)
add_to_preamble(document, "\\providecommand{\\solutionname}{Solution}")
# check if it is the starred version
star = "*" if "*" in document.body[i] else ""
# now output TeX code
- cmd = "\\vspace%s{%s}" % (star, latex_length(baselineskip)[1])
+ cmd = f"\\vspace{star}{{{latex_length(baselineskip)[1]}}}"
document.body[i : end + 1] = put_cmd_in_ert(cmd)
i += 8
continue
# output space inset as TeX code
baselineskip = document.body[i].split()[-1]
star = "*" if "*" in document.body[i - 1] else ""
- cmd = "\\hspace%s{%s}" % (star, latex_length(baselineskip)[1])
+ cmd = f"\\hspace{star}{{{latex_length(baselineskip)[1]}}}"
document.body[begin : end + 1] = put_cmd_in_ert(cmd)