Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread Stephan Witt
Am 31.07.2022 um 12:41 schrieb José Matos :
> 
> On Sun, 2022-07-31 at 11:16 +0200, Pavel Sanda wrote:
>> Sure, whatever you need :)
>> The patch is in.
>> 
>> Pavel
> 
> First attempt. :-)
> 
> The code is straightforward, on my system it works in both python2 and
> python3. FWIW the only difference is:
> 
> --- configure2.log  2022-07-31 11:32:45.733253492 +0100
> +++ configure.log   2022-07-31 11:33:20.607195627 +0100
> @@ -1,4 +1,4 @@
> -INFO: +Running LyX configure with Python 2.7.18
> +INFO: +Running LyX configure with Python 3.10.5
> INFO: checking for a Latex2e program...
> DEBUG: (latex $$i,latex2e $$i)
> INFO: +checking for "latex"...  yes
> 
> And of course that is the expected.
> 
> FWIW the code should work on any system/OS... famous last words, I
> know. :-D
> 
> Please test it.

With Python 3.8.13 on macOS there is no difference in configure.log before and 
after change c041925261.

Stephan
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 20:30 +0200, Pavel Sanda wrote:
> Will take little time, hopefully tomorrow. P

No problem. :-)
-- 
José Abílio
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 20:09 +0200, Pavel Sanda wrote:
> It's in. Pavel

Thank you. :-)
-- 
José Abílio
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread Pavel Sanda
On Sun, Jul 31, 2022 at 11:41:02AM +0100, José Matos wrote:
> Please test it.

Will take little time, hopefully tomorrow. P
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread Pavel Sanda
On Sun, Jul 31, 2022 at 06:37:29PM +0100, José Matos wrote:
> On Sun, 2022-07-31 at 11:16 +0200, Pavel Sanda wrote:
> > On Sun, Jul 31, 2022 at 07:15:29AM +0100, José Matos wrote:
> > > Now in the context of the pyupgrade fixes this is applied to top
> > > /lib
> > > scripts. I need this before working on configure.py.
> > 
> > Sure, whatever you need :)
> > The patch is in.
> > 
> > Pavel
> 
> Third iteration now regarding the python files in lib/scripts. Solves
> the same issues identified before.

It's in. Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 11:16 +0200, Pavel Sanda wrote:
> On Sun, Jul 31, 2022 at 07:15:29AM +0100, José Matos wrote:
> > Now in the context of the pyupgrade fixes this is applied to top
> > /lib
> > scripts. I need this before working on configure.py.
> 
> Sure, whatever you need :)
> The patch is in.
> 
> Pavel

Third iteration now regarding the python files in lib/scripts. Solves
the same issues identified before.

-- 
José Abílio
diff --git a/lib/scripts/fig2pdftex.py b/lib/scripts/fig2pdftex.py
index b458ccd8f3..10e9c5a89d 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 88ada1213e..c2fc7c20a7 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 8effd5bd00..29eb833f54 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 2aaf2db42b..affef65644 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 09256da7cb..a0f2bedfe1 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 eee000deea..719738d002 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: Wrong commit ?

2022-07-31 Thread Kornel Benko
Am Sun, 31 Jul 2022 18:48:01 +0200
schrieb Jean-Pierre Chrétien :

> Dear Developers,
> 
> While committing a very minor change in the French UserGuide, I had a warning 
> about the fact that I was in "Detached HEAD mode".
> 
> I committed nevertheless, but I see in the log that there is something fishy:
> 
> 
> $ git log
> commit 4c72d8aeac01c53e27732999108f249356e67c5c (HEAD -> master, 
> origin/master, 
> origin/HEAD)
> Author: jpc 
> Date:   Sun Jul 31 18:28:23 2022 +0200
> 
>  Info in French UserGuide
> 
> commit c04192526187c1b3bfe7d7dcabd9cd6c50084642
> Author: Pavel Sanda 
> Date:   Sun Jul 31 11:13:53 2022 +0200
> 
>  pyupgrade related fixes to python scripts #2.
> 
>  Patch from Jose.
>  https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg21.html
> 
> 
> Is my commit in the right place?
> 
> What should I do to return to normal behavior?
> Should I run
> 
> $git switch -

Maybe
$ git checkout master
?

> from what I understand from the inline explanations?
> 

Looks OK here.

commit 4c72d8ae
Author: jpc 
AuthorDate: Sun Jul 31 18:28:23 2022 +0200
Commit: jpc 
CommitDate: Sun Jul 31 18:29:23 2022 +0200

Info in French UserGuide


pgpsI589IjD6V.pgp
Description: Digitale Signatur von OpenPGP
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 07:15 +0100, José Matos wrote:
> In order to keep some sanity Python does not allow to stack
> prefixes, like
> 
>  fur"\begin_layout {layout}"

Actually thinking a bit and researching a little more this is wrong:
https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Looking in to the Python Language reference I see that it is possible
to use mix two:
stringprefix  ::=  "r" | "u" | "R" | "U" | "f" | "F"
| "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"

The issue that confused me is that since we need to keep the
compatibility with python2 we need to use the u prefix.

The u prefix was supported in Python 3 just version 3.3. Previously it
was available in python2:
"New in version 3.3: Support for the unicode legacy literal (u'value')
was reintroduced to simplify the maintenance of dual Python 2.x and 3.x
codebases. See PEP 414 for more information."

So actually the code above could simply be used as
fr"\begin_layout {layout}"

this only works for Python 3.6+, when the formatted strings were
introduced.

Apologies for this series of Python musings. :-D
-- 
José Abílio
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Wrong commit ?

2022-07-31 Thread Jean-Pierre Chrétien

Dear Developers,

While committing a very minor change in the French UserGuide, I had a warning 
about the fact that I was in "Detached HEAD mode".


I committed nevertheless, but I see in the log that there is something fishy:


$ git log
commit 4c72d8aeac01c53e27732999108f249356e67c5c (HEAD -> master, origin/master, 
origin/HEAD)

Author: jpc 
Date:   Sun Jul 31 18:28:23 2022 +0200

Info in French UserGuide

commit c04192526187c1b3bfe7d7dcabd9cd6c50084642
Author: Pavel Sanda 
Date:   Sun Jul 31 11:13:53 2022 +0200

pyupgrade related fixes to python scripts #2.

Patch from Jose.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg21.html


Is my commit in the right place?

What should I do to return to normal behavior?
Should I run

$git switch -

from what I understand from the inline explanations?

--
Jean-Pierre




--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Do not override (Back)Tab in Adv F when it is useful

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 13:52 +0200, Jean-Marc Lasgouttes wrote:
> Thanks for the offer José, but I took a different way, which does not
> change the  syntax. I have not documented it yet though.
> 
> JMarc 

That is nice to know. :-)

-- 
José Abílio
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Do not override (Back)Tab in Adv F when it is useful

2022-07-31 Thread Jean-Marc Lasgouttes
Thanks for the offer José, but I took a different way, which does not change 
the  syntax. I have not documented it yet though.

JMarc 

Le 31 juillet 2022 12:50:34 GMT+02:00, "José Matos"  a 
écrit :

>I can do the python part if you want to. :-)
>
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [patch] Selection stats in statusbar

2022-07-31 Thread Scott Kostyshak
On Sun, Jul 31, 2022 at 11:34:25AM +0200, Pavel Sanda wrote:
> On Sun, Jul 31, 2022 at 05:16:17AM -0400, Scott Kostyshak wrote:
> > I'm on vacation and won't be able to test for a few weeks. Can you do
> > the test I described before? Just select a big document, and then hold
> > Shift +  to decrease the selection towards the beginning of the
> > document. I just counted using a wrist stopwatch and compared
> > with/without the patch.
> 
> I did that already and haven't seen noticeable lag. But I might have too 
> powerful machine, that's why I ask. Anyway, increasing delay would be
> trivial change later.

That's good enough for me. 0.5 seems fine to me and I imagine it could
even be decreased. If anyone wanted to do extra work, they could try to
figure out how long the delay in Libre Office or Word is.

I was more worried that there was unintended computation being done
outside of the delayed computation so this addresses that as far as I'm
concerned.

> > I did not look, but will this be on by default? Would you object to a
> > way to turn off the stats, like we have a way to turn off the zoom level
> > and slider in the status bar?
> 
> Already done. You can disable it in the same way you can disappear zoom 
> slider.

Perfect, thanks!

Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [LyX/master] Do not override (Back)Tab in Adv F when it is useful

2022-07-31 Thread José Matos
On Tue, 2022-07-19 at 10:10 +0200, Jean-Marc Lasgouttes wrote:
> However, I am not sure how to implement the prefs2prefs part, firstly
> because one have to handle quotes (or absence thereof) and spaces and
> secondly because I am bad at python.
> 
> So do we want to do this for 2.4? I can do all the non-python part.
> 
> JMarc

I can do the python part if you want to. :-)

Best regards,
-- 
José Abílio
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 11:16 +0200, Pavel Sanda wrote:
> Sure, whatever you need :)
> The patch is in.
> 
> Pavel

First attempt. :-)

The code is straightforward, on my system it works in both python2 and
python3. FWIW the only difference is:

--- configure2.log  2022-07-31 11:32:45.733253492 +0100
+++ configure.log   2022-07-31 11:33:20.607195627 +0100
@@ -1,4 +1,4 @@
-INFO: +Running LyX configure with Python 2.7.18
+INFO: +Running LyX configure with Python 3.10.5
 INFO: checking for a Latex2e program...
 DEBUG: (latex $$i,latex2e $$i)
 INFO: +checking for "latex"...  yes

And of course that is the expected.

FWIW the code should work on any system/OS... famous last words, I
know. :-D

Please test it.
-- 
José Abílio
diff --git a/lib/configure.py b/lib/configure.py
index ab205dd7b4..baf82929cb 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1174,8 +1174,18 @@ def checkConverterEntries():
 checkProg('an EPS -> PDF converter', ['epstopdf'],
 rc_entry = [ r'\converter epspdf6   "epstopdf --outfile=$$o $$i"	""'])
 #
-checkProg('an EPS -> PNG converter', ['magick $$i[0] $$o', 'convert $$i[0] $$o'],
-rc_entry = [ r'\converter epspng"%%"	""'])
+# Due to more restrictive policies, it is possible that (image)magick
+# does not allow conversions from eps to png.
+# So before setting the converter test it it on a mock file
+_, cmd = checkProg('an EPS -> PNG converter', ['magick', 'convert'])
+if cmd:
+writeToFile('mock.eps', r'%!PS')
+if subprocess.check_call([cmd, "mock.eps", "mock.png"]) == 0:
+rc_entry = r'\converter epspng"%s $$i[0] $$o"	""'
+addToRC(rc_entry % cmd)
+removeFiles(['mock.eps', 'mock.png'])
+else:
+removeFiles(['mock.eps'])
 #
 # no agr -> pdf6 converter, since the pdf library used by gracebat is not
 # free software and therefore not compiled in in many installations.
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [patch] Selection stats in statusbar

2022-07-31 Thread Pavel Sanda
On Sun, Jul 31, 2022 at 05:16:17AM -0400, Scott Kostyshak wrote:
> I'm on vacation and won't be able to test for a few weeks. Can you do
> the test I described before? Just select a big document, and then hold
> Shift +  to decrease the selection towards the beginning of the
> document. I just counted using a wrist stopwatch and compared
> with/without the patch.

I did that already and haven't seen noticeable lag. But I might have too 
powerful machine, that's why I ask. Anyway, increasing delay would be
trivial change later.

> I did not look, but will this be on by default? Would you object to a
> way to turn off the stats, like we have a way to turn off the zoom level
> and slider in the status bar?

Already done. You can disable it in the same way you can disappear zoom slider.

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: [patch] Selection stats in statusbar

2022-07-31 Thread Scott Kostyshak
On Sun, Jul 31, 2022 at 12:35:30AM +0200, Pavel Sanda wrote:
> On Fri, Jul 15, 2022 at 12:05:25AM +0200, Pavel Sanda wrote:
> > On Thu, Jul 14, 2022 at 09:31:06AM +0200, Daniel wrote:
> > > >The drawback is that's it's difficult to understand the interaction 
> > > >between
> > > >the two timers now. I stared on the code for couple minutes and it was
> > > >not clear to me what is the idea behind your stop/start changes.
> > > 
> > > Some comments would probably have been good. I could try to add them if
> > > there is interest.
> > 
> > If I find little time I'll try the QTimer route and see whether we converge 
> > :)
> 
> So I tried to find the best from solution from both worlds.
> In the attached patch we use QTimer (0.5s between updates) for updating stats.
> To avoid tricky interactions with another timer and current messages in
> status bar I simply cretaed completely new label next to the slider, so it's
> independent mechanism with no interactions.
> 
> On top of that its possible to disable the visibility via context menu, but 
> it's
> part of session not new RC variable, which seems good enough compromise.
> 
> The update interval is now 0.5s, let me know if there is any slugishness
> in your testing. I didn't see any, but I can easliy increase to 1s if need be.
> 
> Any objections now?
> 
> Pavel

I'm on vacation and won't be able to test for a few weeks. Can you do
the test I described before? Just select a big document, and then hold
Shift +  to decrease the selection towards the beginning of the
document. I just counted using a wrist stopwatch and compared
with/without the patch.

I did not look, but will this be on by default? Would you object to a
way to turn off the stats, like we have a way to turn off the zoom level
and slider in the status bar? If you would object, I suggest we take a
poll on lyx-users. I would vote against it (since I don't like numbers
changing as I change the selection) but I have a feeling most users
would be in favor of it, and I would be fine with that result.

Scott


signature.asc
Description: PGP signature
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread Pavel Sanda
On Sun, Jul 31, 2022 at 07:15:29AM +0100, José Matos wrote:
> Now in the context of the pyupgrade fixes this is applied to top /lib
> scripts. I need this before working on configure.py.

Sure, whatever you need :)
The patch is in.

Pavel
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: LYXERR0 / lyxerr Output Discrepancies

2022-07-31 Thread Jean-Marc Lasgouttes
Hi Joel,

LYXERR0 and LYXERR are wrappers around lyxerr. They are normally the preferred  
form.

JMarc 

Le 31 juillet 2022 03:50:50 GMT+02:00, Joel Kulesza  a 
écrit :
>Is there a reason that these diagnostic messages have different approaches
>and forms (maybe to avoid constructing a string to send to LYXERR0)?  If
>unintentional, is there a preferred form (mine would be the former)?  If
>so, is there interest in me submitting a patch to unify toward a
>consistent approach?

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel


Re: Interesting discovery from automatic tools (python code)

2022-07-31 Thread José Matos
On Sun, 2022-07-31 at 00:44 +0200, Pavel Sanda wrote:
> Good. This one applies, so it's in now.
> Now that I have you on hotline, any chance to have a look at the
> configure patch we discussed in March? :)
> (Was: LyX 2.4.0 (IM policy.xml ban on eps/pdf conversions))
> 
> Pavel

That was the next item in my list, really. :-)

Now in the context of the pyupgrade fixes this is applied to top /lib
scripts. I need this before working on configure.py.

The idea, of course, is to separate different changes in different
commits.

Again the changes are related with fixing escape sequences.


The two options are either add an r prefix indicating that the string
is raw, thus no escape is performed, or to double the backslash.

Most of the time I would use raw strings with the exception being the
addition of newline \n. The added complication here is that since we
support python 2 some strings need to be marked as unicode, with a u
prefix. In order to keep some sanity Python does not allow to stack
prefixes, like

 fur"\begin_layout {layout}"

The f refers to formatted strings, and thus inside the string {layout}
is replaced with the value of the layout expression, u makes the string
unicode (the default in Python 3 and thus a no-op in Python3) and r
would mean raw string and thus the first backslash is not escaped.

-- 
José Abílio
diff --git a/lib/configure.py b/lib/configure.py
index 132141dc3a..ab205dd7b4 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -705,7 +705,7 @@ texteditors = ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate',
'xed', 'notepad', 'WinEdt', 'WinShell', 'PSPad']
 
 def checkFormatEntries(dtl_tools):
-''' Check all formats (\Format entries) '''
+r''' Check all formats (\Format entries) '''
 checkViewerEditor('a Tgif viewer and editor', ['tgif'],
 rc_entry = [r'\Format tgif  "obj, tgo" Tgif "" "%%"	"%%"	"vector"	"application/x-tgif"'])
 #
@@ -876,7 +876,7 @@ def checkFormatEntries(dtl_tools):
 
 
 def checkConverterEntries():
-''' Check all converters (\converter entries) '''
+r''' Check all converters (\converter entries) '''
 checkProg('the pdflatex program', ['pdflatex $$i'],
 rc_entry = [ r'\converter pdflatex   pdf2   "%%"	"latex=pdflatex,hyperref-driver=pdftex"' ])
 
@@ -1269,7 +1269,7 @@ def checkConverterEntries():
 path, lilypond = checkProg('a LilyPond -> EPS/PDF/PNG converter', ['lilypond'])
 if (lilypond):
 version_string = cmdOutput("lilypond --version")
-match = re.match('GNU LilyPond (\S+)', version_string)
+match = re.match(r'GNU LilyPond (\S+)', version_string)
 if match:
 version_number = match.groups()[0]
 version = version_number.split('.')
@@ -1299,7 +1299,7 @@ def checkConverterEntries():
 continue
 found_lilypond_book = True
 
-match = re.match('(\S+)$', version_string)
+match = re.match(r'(\S+)$', version_string)
 if match:
 version_number = match.groups()[0]
 version = version_number.split('.')
@@ -1426,7 +1426,7 @@ def _checkForClassExtension(x):
 return x.strip()
 
 def processLayoutFile(file):
-""" process layout file and get a line of result
+r""" process layout file and get a line of result
 
 Declare lines look like this:
 
@@ -1454,8 +1454,8 @@ def processLayoutFile(file):
 """
 classname = file.split(os.sep)[-1].split('.')[0]
 # return ('[a,b]', 'a', ',b,c', 'article') for \DeclareLaTeXClass[a,b,c]{article}
-p = re.compile('\s*#\s*DeclareLaTeXClass\s*(\[([^,]*)(,.*)*])*\s*{(.*)}\s*$')
-q = re.compile('\s*#\s*DeclareCategory{(.*)}\s*$')
+p = re.compile('\\s*#\\s*DeclareLaTeXClass\\s*(\\[([^,]*)(,.*)*])*\\s*{(.*)}\\s*$')
+q = re.compile('\\s*#\\s*DeclareCategory{(.*)}\\s*$')
 classdeclaration = ""
 categorydeclaration = '""'
 for line in open(file, 'r', encoding='utf8').readlines():
@@ -1547,7 +1547,7 @@ def checkLatexConfig(check_config):
 # Construct the list of classes to test for.
 # build the list of available layout files and convert it to commands
 # for chkconfig.ltx
-declare = re.compile('\\s*#\\s*DeclareLaTeXClass\\s*(\[([^,]*)(,.*)*\])*\\s*{(.*)}\\s*$')
+declare = re.compile('\\s*#\\s*DeclareLaTeXClass\\s*(\\[([^,]*)(,.*)*\\])*\\s*{(.*)}\\s*$')
 category = re.compile('\\s*#\\s*DeclareCategory{(.*)}\\s*$')
 empty = re.compile('\\s*$')
 testclasses = list()
@@ -1563,7 +1563,7 @@ def checkLatexConfig(check_config):
 for line in open(file, 'r', encoding='utf8').readlines():
 if not empty.match(line) and line[0] != '#'[0]:
 if decline == "":
-logger.warning("Failed to find valid \Declare line "
+logger.warning(r"Failed to find valid \Declare line "
 "for layout file