commit 79f321d0f505385438a9fca01ef87a658abf6bc7
Author: Pavel Sanda <[email protected]>
Date: Sun Jul 31 20:08:44 2022 +0200
pyupgrade related fixes to python scripts #2.
Patch from Jose.
https://www.mail-archive.com/[email protected]/msg217790.html
---
lib/scripts/fig2pdftex.py | 2 +-
lib/scripts/layout2layout.py | 8 ++++----
lib/scripts/legacy_lyxpreview2ppm.py | 2 +-
lib/scripts/lyxpak.py | 2 +-
lib/scripts/lyxpaperview.py | 2 +-
lib/scripts/lyxpreview2bitmap.py | 4 ++--
lib/scripts/lyxpreview_tools.py | 1 -
lib/scripts/prefs2prefs_prefs.py | 4 ++--
8 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/lib/scripts/fig2pdftex.py b/lib/scripts/fig2pdftex.py
index b458ccd..10e9c5a 100644
--- a/lib/scripts/fig2pdftex.py
+++ b/lib/scripts/fig2pdftex.py
@@ -78,7 +78,7 @@ else:
# with tetex.
epsfile = outbase + '.pstex'
tmp = mkstemp()
- boundingboxline =
re.compile(b'%%BoundingBox:\s+(\d*)\s+(\d*)\s+(\d*)\s+(\d*)')
+ boundingboxline =
re.compile(br'%%BoundingBox:\s+(\d*)\s+(\d*)\s+(\d*)\s+(\d*)')
for line in open(epsfile, 'rb'):
if line[:13] == b'%%BoundingBox':
(llx, lly, urx, ury) = list(map(int,
boundingboxline.search(line).groups()))
diff --git a/lib/scripts/layout2layout.py b/lib/scripts/layout2layout.py
index 88ada12..c2fc7c2 100644
--- a/lib/scripts/layout2layout.py
+++ b/lib/scripts/layout2layout.py
@@ -457,10 +457,10 @@ def convert(lines, end_format):
re_ChapterStyle = re.compile(b'^\\s*Style\\s+Chapter\\s*$', re.IGNORECASE)
re_InsetLayout_CaptionLTNN =
re.compile(b'^(\\s*InsetLayout\\s+)(Caption:LongTableNonumber)', re.IGNORECASE)
# for format 64
- re_trimLabelString =
re.compile(b'^(\\s*LabelString\s+)"\\s*(.*?)\\s*"\\s*$')
- re_trimLabelStringAppendix =
re.compile(b'^(\\s*LabelStringAppendix\s+)"\\s*(.*?)\\s*"\\s*$')
- re_trimEndLabelString =
re.compile(b'^(\\s*EndLabelString\s+)"\\s*(.*?)\\s*"\\s*$')
- re_trimLabelCounter =
re.compile(b'^(\\s*LabelCounter\s+)"\\s*(.*?)\\s*"\\s*$')
+ re_trimLabelString =
re.compile(b'^(\\s*LabelString\\s+)"\\s*(.*?)\\s*"\\s*$')
+ re_trimLabelStringAppendix =
re.compile(b'^(\\s*LabelStringAppendix\\s+)"\\s*(.*?)\\s*"\\s*$')
+ re_trimEndLabelString =
re.compile(b'^(\\s*EndLabelString\\s+)"\\s*(.*?)\\s*"\\s*$')
+ re_trimLabelCounter =
re.compile(b'^(\\s*LabelCounter\\s+)"\\s*(.*?)\\s*"\\s*$')
# counters for sectioning styles (hardcoded in 1.3)
diff --git a/lib/scripts/legacy_lyxpreview2ppm.py
b/lib/scripts/legacy_lyxpreview2ppm.py
index 8effd5b..29eb833 100644
--- a/lib/scripts/legacy_lyxpreview2ppm.py
+++ b/lib/scripts/legacy_lyxpreview2ppm.py
@@ -156,7 +156,7 @@ def legacy_extract_metrics_info(log_file):
def extract_resolution(log_file, dpi):
fontsize_re = re.compile(b"Preview: Fontsize")
magnification_re = re.compile(b"Preview: Magnification")
- extract_decimal_re = re.compile(b"([0-9\.]+)")
+ extract_decimal_re = re.compile(br"([0-9\.]+)")
extract_integer_re = re.compile(b"([0-9]+)")
found_fontsize = 0
diff --git a/lib/scripts/lyxpak.py b/lib/scripts/lyxpak.py
index 2aaf2db..affef65 100755
--- a/lib/scripts/lyxpak.py
+++ b/lib/scripts/lyxpak.py
@@ -37,7 +37,7 @@ if running_on_windows:
from tempfile import NamedTemporaryFile
# Pre-compiled regular expressions.
-re_lyxfile = re.compile(b"\.lyx$")
+re_lyxfile = re.compile(br"\.lyx$")
re_input = re.compile(b'^(.*)\\\\(input|include){(\\s*)(.+)(\\s*)}.*$')
re_ertinput = re.compile(b'^(input|include)({)(\\s*)(.+)(\\s*)}.*$')
re_package = re.compile(b'^(.*)\\\\(usepackage){(\\s*)(.+)(\\s*)}.*$')
diff --git a/lib/scripts/lyxpaperview.py b/lib/scripts/lyxpaperview.py
index 09256da..a0f2bed 100755
--- a/lib/scripts/lyxpaperview.py
+++ b/lib/scripts/lyxpaperview.py
@@ -78,7 +78,7 @@ def find(args, path):
# use locate if possible (faster)
if find_exe(['locate']):
p1 = subprocess.Popen(['locate', '-i', args[0].lower()],
stdout=subprocess.PIPE)
- px = subprocess.Popen(['grep', '-Ei', '\.pdf$|\.ps$'],
stdin=p1.stdout, stdout=subprocess.PIPE)
+ px = subprocess.Popen(['grep', '-Ei', r'\.pdf$|\.ps$'],
stdin=p1.stdout, stdout=subprocess.PIPE)
for arg in args:
if arg == args[0]:
# have this already
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index eee000d..719738d 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -120,7 +120,7 @@ def extract_metrics_info(dvipng_stdout):
# "\[[0-9]+" can match two kinds of numbers: page numbers from dvipng
# and glyph numbers from mktexpk. The glyph numbers always match
# "\[[0-9]+\]" while the page number never is followed by "\]". Thus:
- page_re = re.compile("\[([0-9]+)[^]]");
+ page_re = re.compile(r"\[([0-9]+)[^]]");
metrics_re = re.compile("depth=(-?[0-9]+) height=(-?[0-9]+)")
success = 0
@@ -197,7 +197,7 @@ def fix_latex_file(latex_file, pdf_output):
def convert_to_ppm_format(pngtopnm, basename):
- png_file_re = re.compile("\.png$")
+ png_file_re = re.compile(r"\.png$")
for png_file in glob.glob("%s*.png" % basename):
ppm_file = png_file_re.sub(".ppm", png_file)
diff --git a/lib/scripts/lyxpreview_tools.py b/lib/scripts/lyxpreview_tools.py
index 7783fe2..cca359e 100644
--- a/lib/scripts/lyxpreview_tools.py
+++ b/lib/scripts/lyxpreview_tools.py
@@ -1,4 +1,3 @@
-
# file lyxpreview_tools.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py
index 08c1f38..78870a3 100644
--- a/lib/scripts/prefs2prefs_prefs.py
+++ b/lib/scripts/prefs2prefs_prefs.py
@@ -223,7 +223,7 @@ def remove_obsolete(line):
def language_use_babel(line):
- if not line.lower().startswith("\language_use_babel"):
+ if not line.lower().startswith(r"\language_use_babel"):
return no_match
re_lub = re.compile(r'^\\language_use_babel\s+"?(true|false)',
re.IGNORECASE)
m = re_lub.match(line)
@@ -364,7 +364,7 @@ def split_pdf_format(line):
viewer = ''
else:
viewer = entries[5]
- converted = line.replace('application/pdf', '') + '''
+ converted = line.replace('application/pdf', '') + r'''
\Format pdf6 pdf "PDF (graphics)" "" "''' + viewer + '"
"" "vector" "application/pdf"'
return (True, converted)
elif line.lower().startswith("\\viewer_alternatives") or \
--
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs