Re: [LyX/master] python3: fix the preview framework to work with both python 2 and 3

2017-05-09 Thread José Abílio Matos
On Tuesday, 9 May 2017 16.06.54 WEST Jean-Marc Lasgouttes wrote:
> I just got the following. Is it related?

Yes. I committed the obvious fix.

Thank you. :-)
-- 
José Abílio


Re: [LyX/master] python3: fix the preview framework to work with both python 2 and 3

2017-05-09 Thread José Abílio Matos
On Tuesday, 9 May 2017 11.21.45 WEST José Matos wrote:
> commit 11f2a59ce90b406537ff3379276d5e0bb1bf6c37
> Author: José Matos 
> Date:   Tue May 9 11:20:34 2017 +0100
> 
> python3: fix the preview framework to work with both python 2 and 3
> ---
>  lib/scripts/legacy_lyxpreview2ppm.py |   16 
>  lib/scripts/lyxpreview2bitmap.py |   28 +++-
>  lib/scripts/lyxpreview_tools.py  |   12 ++--
>  3 files changed, 29 insertions(+), 27 deletions(-)
> 
> diff --git a/lib/scripts/legacy_lyxpreview2ppm.py
> b/lib/scripts/legacy_lyxpreview2ppm.py index 3049b44..6a91402 100644
> --- a/lib/scripts/legacy_lyxpreview2ppm.py
> +++ b/lib/scripts/legacy_lyxpreview2ppm.py
> @@ -79,7 +79,7 @@
>  # If possible, the script will use pdftocairo instead of gs,
>  # as it's much faster and gives better results.
> 
> -import glob, os, pipes, re, string, sys
> +import glob, os, pipes, re, sys
> 
>  from lyxpreview_tools import check_latex_log, copyfileobj, error,
> filter_pages,\ find_exe, find_exe_or_terminate, join_metrics_and_rename,
> latex_commands, \ @@ -118,8 +118,8 @@ def
> legacy_extract_metrics_info(log_file):
>  error("Unexpected data in %s\n%s" % (log_file, line))
> 
>  if snippet:
> -ascent  = string.atof(match.group(2))
> -descent = string.atof(match.group(3))
> +ascent  = float(match.group(2))
> +descent = float(match.group(3))

This is an example of what we get when running lyx with python3. Now the latex 
preview works also for python 3.

FWIW most of the changes were from functions that were deprecated since python 
2.0. The final version of Python 2.0 was released on October 16, 2000. So it 
was not as if we had not enough time to change this.

The functions are
string.atoi -> int
string.atof -> float
string.join -> " ".join

In fairness it was Bo Peng who converted this code, from perl, and he warned 
in the commit thread that he did not know python so well but he wanted to 
ensure that all our scripts run with python.

Regards,
-- 
José Abílio