commit 3f03f0a447e0f672025d78881d8a2790133ff47b
Author: José Matos <[email protected]>
Date: Sat Dec 29 19:14:41 2018 +0000
Move all python shebangs from /usr/bin/env to python3.
The change is only relevant to development as all the call to python
scripts is done
calling C++ os::python that invoques the appropriate python version.
The change is two fold, on one hand remove all the uses of /usr/bin/env for
python.
On the other hand rename all the calls to python from python to python3
making it explicit
and being compliant with PEP 394 -- The "python" Command on Unix-Like
Systems:
https://www.python.org/dev/peps/pep-0394/
Remove the sheebang from src/graphics/GraphicsConverter.cpp because it is
not necessary.
Some small whitespace changes.
---
development/cmake/doc/ReplaceValues.py | 2 +-
development/cmake/po/cat.py | 2 +-
development/cmake/po/unix2dos.py | 6 ++--
development/cmake/po/update-gmo.py | 2 +-
development/tools/gen_lfuns.py | 48 +++++++++++++-------------
development/tools/generate_symbols_images.py | 2 +-
development/tools/generate_symbols_list.py | 2 +-
development/tools/mergepo.py | 2 +-
development/tools/unicodesymbols.py | 2 +-
development/tools/updatedocs.py | 2 +-
development/tools/updatelayouts.py | 4 +-
po/lyx_pot.py | 4 +--
po/postats.py | 4 +-
src/graphics/GraphicsConverter.cpp | 3 +-
src/tex2lyx/test/runtests.py | 3 +-
15 files changed, 42 insertions(+), 46 deletions(-)
diff --git a/development/cmake/doc/ReplaceValues.py
b/development/cmake/doc/ReplaceValues.py
index da1d42a..18eaab3 100755
--- a/development/cmake/doc/ReplaceValues.py
+++ b/development/cmake/doc/ReplaceValues.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
from __future__ import print_function
diff --git a/development/cmake/po/cat.py b/development/cmake/po/cat.py
index 7a1ee26..0462b29 100644
--- a/development/cmake/po/cat.py
+++ b/development/cmake/po/cat.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
from __future__ import print_function
diff --git a/development/cmake/po/unix2dos.py b/development/cmake/po/unix2dos.py
index 85af0ec..2812873 100644
--- a/development/cmake/po/unix2dos.py
+++ b/development/cmake/po/unix2dos.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
###############
import sys
@@ -11,7 +11,7 @@ for fname in sys.argv[1:]:
if len(outstr) == len(instr):
continue
-
+
outfile = open( fname , "wb" )
outfile.write( outstr )
- outfile.close()
\ No newline at end of file
+ outfile.close()
diff --git a/development/cmake/po/update-gmo.py
b/development/cmake/po/update-gmo.py
index 8e0c108..1758755 100644
--- a/development/cmake/po/update-gmo.py
+++ b/development/cmake/po/update-gmo.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
###############
import sys, os, shutil
diff --git a/development/tools/gen_lfuns.py b/development/tools/gen_lfuns.py
index 64dc7dc..6162bbb 100755
--- a/development/tools/gen_lfuns.py
+++ b/development/tools/gen_lfuns.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file gen_lfuns.py
@@ -39,7 +39,7 @@ LFUN_SAMPLE_ID = u"\\li Sample: "
LFUN_ORIGIN_ID = u"\\li Origin: "
LFUN_ENDVAR = u"\\endvar"
-ID_DICT = dict(name=LFUN_NAME_ID, action=LFUN_ACTION_ID,
notion=LFUN_NOTION_ID,
+ID_DICT = dict(name=LFUN_NAME_ID, action=LFUN_ACTION_ID, notion=LFUN_NOTION_ID,
syntax=LFUN_SYNTAX_ID, params=LFUN_PARAMS_ID,
sample=LFUN_SAMPLE_ID, origin=LFUN_ORIGIN_ID)
LFUNS_HEADER = u"""# gen_lfuns.py generated this file. For more info see
http://www.lyx.org/
@@ -153,7 +153,7 @@ About this manual
\\end_layout
\\begin_layout Standard
-This manual documents the
+This manual documents the
\\begin_inset Quotes eld
\\end_inset
@@ -175,7 +175,7 @@ LFUNs are also used in the files that define keyboard
shortcuts, menu or
So if you want to change\\SpecialChar breakableslash
customize the user interface, you need to deal
with LFUNs.
- Furthermore, external programs can use LFUNs to communicate with and
+ Furthermore, external programs can use LFUNs to communicate with and
\\begin_inset Quotes eld
\\end_inset
@@ -186,7 +186,7 @@ remote-control
\\SpecialChar LyX
.
Finally, you can also issue LFUNs directly via the so called mini-buffer
- which can be opened via
+ which can be opened via
\\begin_inset Info
type "shortcuts"
arg "command-execute"
@@ -208,15 +208,15 @@ LFUNS_FOOTER = u"""\\end_body
def parse_lfun(str):
"""Takes a comment block (str) and parses it for fields describing the
LFUN. Returns a dict containing the fields."""
-
+
lfun = dict(action="", notion="", syntax="", params="", sample="",
origin="")
field = ""
lines = str.splitlines()
- # strip leading whitespace and * from the lines of the comment to get
+ # strip leading whitespace and * from the lines of the comment to get
# rid of unimportant characters
for i in range(0, len(lines)):
lines[i] = lines[i].strip(" *")
-
+
for i in range(0, len(lines) - 1):
# work out what field is being read if none of these is found, the
line will be added
# to the last field edited
@@ -257,11 +257,11 @@ def parse_lfun(str):
pre_space = ""
else:
pre_space = " "
-
+
# add the line to the field, processing it for \ characters and \n
# which, if occurring at the end of a line, must become a LYX_NEWLINE
line = lines[i][skip:]
-
+
# deal with \htmlonly
# TODO: convert chars found in htmlonly to unicode
start = line.find(HTMLONLY_START)
@@ -276,7 +276,7 @@ def parse_lfun(str):
#else:
# TODO: if HTMLONLY_END is not found, look on the next line
# TODO: in the current LyXAction.cpp there are no htmlonly fields
which go over a line break
-
+
# deal with \ but leave \n if at the end of the line
slash_idx = line.find("\\")
while slash_idx >= 0:
@@ -284,7 +284,7 @@ def parse_lfun(str):
or slash_idx == len(line)-1:
# true when the \ is not the last or second last char
# or when the slash is the last char of the line
-
+
# slash must be interpreted literaly so swap it for a
LYX_BACKSLASH
line = line[:slash_idx] + LYX_BACKSLASH + line[slash_idx+1:]
# skip the index ahead beyond the added text
@@ -292,10 +292,10 @@ def parse_lfun(str):
elif line[slash_idx+1] != "n": # only evaluated if the line ends
"\x" where 'x' != 'n'
line = line[:slash_idx] + LYX_BACKSLASH + line[slash_idx+1:]
# skip the index ahead beyond the added text
- slash_idx = slash_idx + len(LYX_BACKSLASH)
+ slash_idx = slash_idx + len(LYX_BACKSLASH)
# look for the next \
slash_idx = line.find("\\", slash_idx+1)
-
+
# \n at the end of lines will not be processed by the above while loop
# so sort those out now
# sometime lines end " \n" so chop the space if its there
@@ -303,11 +303,11 @@ def parse_lfun(str):
line = line[:len(line)-3] + LYX_NEWLINE
elif line.endswith("\\n"):
line = line[:len(line)-2] + LYX_NEWLINE
-
+
# any references to other LFUNs need the # removing
# TODO: actually insert a cross-reference here
line = line.replace("#LFUN", "LFUN")
-
+
# handle the few #lyx:: cases
line = line.replace("#lyx::", "lyx::")
@@ -316,9 +316,9 @@ def parse_lfun(str):
# to avoid an error
if field != "":
lfun[field] = lfun[field] + pre_space + line
-
+
# TODO: sort out chopping lines of more that 80 chars in length
-
+
return lfun
def write_fields(file, lfun):
@@ -379,7 +379,7 @@ def write_sections(file,lfuns):
for lf in lfuns:
if lf["type"] == val:
write_fields(file, lf)
-
+
def main(argv):
# parse command line arguments
script_path, script_name = os.path.split(argv[0])
@@ -408,7 +408,7 @@ def main(argv):
lyxaction_text = lyxaction_file.read()
lfuns_file.write(LFUNS_HEADER)
-
+
# An introductory section
lfuns_file.write(LFUNS_INTRO)
@@ -452,7 +452,7 @@ def main(argv):
done = 1
lfun_list = sorted(lfun_list_unsorted, key=lambda k: k['name'])
-
+
# write the lfuns to the file
write_sections(lfuns_file, lfun_list)
@@ -460,11 +460,11 @@ def main(argv):
# write the last part of LFUNs.lyx
lfuns_file.write(LFUNS_FOOTER)
-
+
lyxaction_file.close()
lfuns_file.close()
-
+
sys.stderr.write(script_name + ": Finished\n")
-
+
if __name__ == "__main__":
main(sys.argv)
diff --git a/development/tools/generate_symbols_images.py
b/development/tools/generate_symbols_images.py
index 91d685c..f3ea8e1 100755
--- a/development/tools/generate_symbols_images.py
+++ b/development/tools/generate_symbols_images.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file generate_symbols_images.py
diff --git a/development/tools/generate_symbols_list.py
b/development/tools/generate_symbols_list.py
index d640a6b..5b2963d 100755
--- a/development/tools/generate_symbols_list.py
+++ b/development/tools/generate_symbols_list.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file generate_symbols_images.py
diff --git a/development/tools/mergepo.py b/development/tools/mergepo.py
index a86b75d..c54448c 100755
--- a/development/tools/mergepo.py
+++ b/development/tools/mergepo.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file mergepo.py
diff --git a/development/tools/unicodesymbols.py
b/development/tools/unicodesymbols.py
index 7338d2f..b67364b 100755
--- a/development/tools/unicodesymbols.py
+++ b/development/tools/unicodesymbols.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file unciodesymbols.py
diff --git a/development/tools/updatedocs.py b/development/tools/updatedocs.py
index 9101099..41fe091 100755
--- a/development/tools/updatedocs.py
+++ b/development/tools/updatedocs.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file updatedocs.py
diff --git a/development/tools/updatelayouts.py
b/development/tools/updatelayouts.py
index 67127d6..eaef163 100755
--- a/development/tools/updatelayouts.py
+++ b/development/tools/updatelayouts.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file updatelayouts.py
@@ -30,7 +30,7 @@ def main(argv):
(base, ext) = os.path.splitext(i)
if ext == ".old":
continue
- args = ["layout2layout", i + ".old", i]
+ args = ["layout2layout", i + ".old", i]
shutil.copy(args[2], args[1])
layout2layout(args)
diff --git a/po/lyx_pot.py b/po/lyx_pot.py
index 173d29e..5c8502c 100755
--- a/po/lyx_pot.py
+++ b/po/lyx_pot.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
# -*- coding: utf-8 -*-
# file lyx_pot.py
@@ -698,5 +698,3 @@ if __name__ == '__main__':
encodings_l10n(input_files, output, base)
else:
languages_l10n(input_files, output, base)
-
-
diff --git a/po/postats.py b/po/postats.py
index fe48651..8c5f058 100755
--- a/po/postats.py
+++ b/po/postats.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (C) 2007 Michael Gerz <[email protected]>
# Copyright (C) 2007 José Matos <[email protected]>
@@ -40,7 +40,7 @@ import sys
# Reset the locale
import locale
-locale.setlocale(locale.LC_ALL, 'C')
+locale.setlocale(locale.LC_ALL, 'C')
os.environ['LC_ALL'] = 'C'
def extract_number(line, issues, prop):
diff --git a/src/graphics/GraphicsConverter.cpp
b/src/graphics/GraphicsConverter.cpp
index f00f017..6c3e48d 100644
--- a/src/graphics/GraphicsConverter.cpp
+++ b/src/graphics/GraphicsConverter.cpp
@@ -287,8 +287,7 @@ static void build_script(string const & doc_fname,
LYXERR(Debug::GRAPHICS, "build_script ... ");
typedef Graph::EdgePath EdgePath;
- script << "#!/usr/bin/env python\n"
- "# -*- coding: utf-8 -*-\n"
+ script << "# -*- coding: utf-8 -*-\n"
"import os, shutil, sys\n\n"
"def unlinkNoThrow(file):\n"
" ''' remove a file, do not throw if an error occurs '''\n"
diff --git a/src/tex2lyx/test/runtests.py b/src/tex2lyx/test/runtests.py
index 7bfbfe5..0cebef0 100755
--- a/src/tex2lyx/test/runtests.py
+++ b/src/tex2lyx/test/runtests.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
# -*- coding: utf-8 -*-
# file src/tex2lyx/test/runtests.py
@@ -161,4 +161,3 @@ def getlyxinput(lyx, lyxfx, lyxf, uselyx2lyx):
if __name__ == "__main__":
main(sys.argv)
-