mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
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.
This commit is contained in:
parent
6e2c86a15c
commit
3f03f0a447
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
###############
|
###############
|
||||||
import sys
|
import sys
|
||||||
@ -11,7 +11,7 @@ for fname in sys.argv[1:]:
|
|||||||
|
|
||||||
if len(outstr) == len(instr):
|
if len(outstr) == len(instr):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
outfile = open( fname , "wb" )
|
outfile = open( fname , "wb" )
|
||||||
outfile.write( outstr )
|
outfile.write( outstr )
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
###############
|
###############
|
||||||
import sys, os, shutil
|
import sys, os, shutil
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file gen_lfuns.py
|
# file gen_lfuns.py
|
||||||
@ -39,7 +39,7 @@ LFUN_SAMPLE_ID = u"\\li Sample: "
|
|||||||
LFUN_ORIGIN_ID = u"\\li Origin: "
|
LFUN_ORIGIN_ID = u"\\li Origin: "
|
||||||
LFUN_ENDVAR = u"\\endvar"
|
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)
|
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/
|
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
|
\\end_layout
|
||||||
|
|
||||||
\\begin_layout Standard
|
\\begin_layout Standard
|
||||||
This manual documents the
|
This manual documents the
|
||||||
\\begin_inset Quotes eld
|
\\begin_inset Quotes eld
|
||||||
\\end_inset
|
\\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
|
So if you want to change\\SpecialChar breakableslash
|
||||||
customize the user interface, you need to deal
|
customize the user interface, you need to deal
|
||||||
with LFUNs.
|
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
|
\\begin_inset Quotes eld
|
||||||
\\end_inset
|
\\end_inset
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ remote-control
|
|||||||
\\SpecialChar LyX
|
\\SpecialChar LyX
|
||||||
.
|
.
|
||||||
Finally, you can also issue LFUNs directly via the so called mini-buffer
|
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
|
\\begin_inset Info
|
||||||
type "shortcuts"
|
type "shortcuts"
|
||||||
arg "command-execute"
|
arg "command-execute"
|
||||||
@ -208,15 +208,15 @@ LFUNS_FOOTER = u"""\\end_body
|
|||||||
|
|
||||||
def parse_lfun(str):
|
def parse_lfun(str):
|
||||||
"""Takes a comment block (str) and parses it for fields describing the LFUN. Returns a dict containing the fields."""
|
"""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="")
|
lfun = dict(action="", notion="", syntax="", params="", sample="", origin="")
|
||||||
field = ""
|
field = ""
|
||||||
lines = str.splitlines()
|
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
|
# rid of unimportant characters
|
||||||
for i in range(0, len(lines)):
|
for i in range(0, len(lines)):
|
||||||
lines[i] = lines[i].strip(" *")
|
lines[i] = lines[i].strip(" *")
|
||||||
|
|
||||||
for i in range(0, len(lines) - 1):
|
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
|
# work out what field is being read if none of these is found, the line will be added
|
||||||
# to the last field edited
|
# to the last field edited
|
||||||
@ -257,11 +257,11 @@ def parse_lfun(str):
|
|||||||
pre_space = ""
|
pre_space = ""
|
||||||
else:
|
else:
|
||||||
pre_space = " "
|
pre_space = " "
|
||||||
|
|
||||||
# add the line to the field, processing it for \ characters and \n
|
# 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
|
# which, if occurring at the end of a line, must become a LYX_NEWLINE
|
||||||
line = lines[i][skip:]
|
line = lines[i][skip:]
|
||||||
|
|
||||||
# deal with \htmlonly
|
# deal with \htmlonly
|
||||||
# TODO: convert chars found in htmlonly to unicode
|
# TODO: convert chars found in htmlonly to unicode
|
||||||
start = line.find(HTMLONLY_START)
|
start = line.find(HTMLONLY_START)
|
||||||
@ -276,7 +276,7 @@ def parse_lfun(str):
|
|||||||
#else:
|
#else:
|
||||||
# TODO: if HTMLONLY_END is not found, look on the next line
|
# 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
|
# 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
|
# deal with \ but leave \n if at the end of the line
|
||||||
slash_idx = line.find("\\")
|
slash_idx = line.find("\\")
|
||||||
while slash_idx >= 0:
|
while slash_idx >= 0:
|
||||||
@ -284,7 +284,7 @@ def parse_lfun(str):
|
|||||||
or slash_idx == len(line)-1:
|
or slash_idx == len(line)-1:
|
||||||
# true when the \ is not the last or second last char
|
# true when the \ is not the last or second last char
|
||||||
# or when the slash is the last char of the line
|
# or when the slash is the last char of the line
|
||||||
|
|
||||||
# slash must be interpreted literaly so swap it for a LYX_BACKSLASH
|
# slash must be interpreted literaly so swap it for a LYX_BACKSLASH
|
||||||
line = line[:slash_idx] + LYX_BACKSLASH + line[slash_idx+1:]
|
line = line[:slash_idx] + LYX_BACKSLASH + line[slash_idx+1:]
|
||||||
# skip the index ahead beyond the added text
|
# 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'
|
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:]
|
line = line[:slash_idx] + LYX_BACKSLASH + line[slash_idx+1:]
|
||||||
# skip the index ahead beyond the added text
|
# 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 \
|
# look for the next \
|
||||||
slash_idx = line.find("\\", slash_idx+1)
|
slash_idx = line.find("\\", slash_idx+1)
|
||||||
|
|
||||||
# \n at the end of lines will not be processed by the above while loop
|
# \n at the end of lines will not be processed by the above while loop
|
||||||
# so sort those out now
|
# so sort those out now
|
||||||
# sometime lines end " \n" so chop the space if its there
|
# 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
|
line = line[:len(line)-3] + LYX_NEWLINE
|
||||||
elif line.endswith("\\n"):
|
elif line.endswith("\\n"):
|
||||||
line = line[:len(line)-2] + LYX_NEWLINE
|
line = line[:len(line)-2] + LYX_NEWLINE
|
||||||
|
|
||||||
# any references to other LFUNs need the # removing
|
# any references to other LFUNs need the # removing
|
||||||
# TODO: actually insert a cross-reference here
|
# TODO: actually insert a cross-reference here
|
||||||
line = line.replace("#LFUN", "LFUN")
|
line = line.replace("#LFUN", "LFUN")
|
||||||
|
|
||||||
# handle the few #lyx:: cases
|
# handle the few #lyx:: cases
|
||||||
line = line.replace("#lyx::", "lyx::")
|
line = line.replace("#lyx::", "lyx::")
|
||||||
|
|
||||||
@ -316,9 +316,9 @@ def parse_lfun(str):
|
|||||||
# to avoid an error
|
# to avoid an error
|
||||||
if field != "":
|
if field != "":
|
||||||
lfun[field] = lfun[field] + pre_space + line
|
lfun[field] = lfun[field] + pre_space + line
|
||||||
|
|
||||||
# TODO: sort out chopping lines of more that 80 chars in length
|
# TODO: sort out chopping lines of more that 80 chars in length
|
||||||
|
|
||||||
return lfun
|
return lfun
|
||||||
|
|
||||||
def write_fields(file, lfun):
|
def write_fields(file, lfun):
|
||||||
@ -379,7 +379,7 @@ def write_sections(file,lfuns):
|
|||||||
for lf in lfuns:
|
for lf in lfuns:
|
||||||
if lf["type"] == val:
|
if lf["type"] == val:
|
||||||
write_fields(file, lf)
|
write_fields(file, lf)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
# parse command line arguments
|
# parse command line arguments
|
||||||
script_path, script_name = os.path.split(argv[0])
|
script_path, script_name = os.path.split(argv[0])
|
||||||
@ -408,7 +408,7 @@ def main(argv):
|
|||||||
lyxaction_text = lyxaction_file.read()
|
lyxaction_text = lyxaction_file.read()
|
||||||
|
|
||||||
lfuns_file.write(LFUNS_HEADER)
|
lfuns_file.write(LFUNS_HEADER)
|
||||||
|
|
||||||
# An introductory section
|
# An introductory section
|
||||||
lfuns_file.write(LFUNS_INTRO)
|
lfuns_file.write(LFUNS_INTRO)
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ def main(argv):
|
|||||||
done = 1
|
done = 1
|
||||||
|
|
||||||
lfun_list = sorted(lfun_list_unsorted, key=lambda k: k['name'])
|
lfun_list = sorted(lfun_list_unsorted, key=lambda k: k['name'])
|
||||||
|
|
||||||
# write the lfuns to the file
|
# write the lfuns to the file
|
||||||
write_sections(lfuns_file, lfun_list)
|
write_sections(lfuns_file, lfun_list)
|
||||||
|
|
||||||
@ -460,11 +460,11 @@ def main(argv):
|
|||||||
|
|
||||||
# write the last part of LFUNs.lyx
|
# write the last part of LFUNs.lyx
|
||||||
lfuns_file.write(LFUNS_FOOTER)
|
lfuns_file.write(LFUNS_FOOTER)
|
||||||
|
|
||||||
lyxaction_file.close()
|
lyxaction_file.close()
|
||||||
lfuns_file.close()
|
lfuns_file.close()
|
||||||
|
|
||||||
sys.stderr.write(script_name + ": Finished\n")
|
sys.stderr.write(script_name + ": Finished\n")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file generate_symbols_images.py
|
# file generate_symbols_images.py
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file generate_symbols_images.py
|
# file generate_symbols_images.py
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file mergepo.py
|
# file mergepo.py
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file unciodesymbols.py
|
# file unciodesymbols.py
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file updatedocs.py
|
# file updatedocs.py
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file updatelayouts.py
|
# file updatelayouts.py
|
||||||
@ -30,7 +30,7 @@ def main(argv):
|
|||||||
(base, ext) = os.path.splitext(i)
|
(base, ext) = os.path.splitext(i)
|
||||||
if ext == ".old":
|
if ext == ".old":
|
||||||
continue
|
continue
|
||||||
args = ["layout2layout", i + ".old", i]
|
args = ["layout2layout", i + ".old", i]
|
||||||
shutil.copy(args[2], args[1])
|
shutil.copy(args[2], args[1])
|
||||||
layout2layout(args)
|
layout2layout(args)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file lyx_pot.py
|
# file lyx_pot.py
|
||||||
@ -698,5 +698,3 @@ if __name__ == '__main__':
|
|||||||
encodings_l10n(input_files, output, base)
|
encodings_l10n(input_files, output, base)
|
||||||
else:
|
else:
|
||||||
languages_l10n(input_files, output, base)
|
languages_l10n(input_files, output, base)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (C) 2007 Michael Gerz <michael.gerz@teststep.org>
|
# Copyright (C) 2007 Michael Gerz <michael.gerz@teststep.org>
|
||||||
# Copyright (C) 2007 José Matos <jamatos@lyx.org>
|
# Copyright (C) 2007 José Matos <jamatos@lyx.org>
|
||||||
@ -40,7 +40,7 @@ import sys
|
|||||||
|
|
||||||
# Reset the locale
|
# Reset the locale
|
||||||
import locale
|
import locale
|
||||||
locale.setlocale(locale.LC_ALL, 'C')
|
locale.setlocale(locale.LC_ALL, 'C')
|
||||||
os.environ['LC_ALL'] = 'C'
|
os.environ['LC_ALL'] = 'C'
|
||||||
|
|
||||||
def extract_number(line, issues, prop):
|
def extract_number(line, issues, prop):
|
||||||
|
@ -287,8 +287,7 @@ static void build_script(string const & doc_fname,
|
|||||||
LYXERR(Debug::GRAPHICS, "build_script ... ");
|
LYXERR(Debug::GRAPHICS, "build_script ... ");
|
||||||
typedef Graph::EdgePath EdgePath;
|
typedef Graph::EdgePath EdgePath;
|
||||||
|
|
||||||
script << "#!/usr/bin/env python\n"
|
script << "# -*- coding: utf-8 -*-\n"
|
||||||
"# -*- coding: utf-8 -*-\n"
|
|
||||||
"import os, shutil, sys\n\n"
|
"import os, shutil, sys\n\n"
|
||||||
"def unlinkNoThrow(file):\n"
|
"def unlinkNoThrow(file):\n"
|
||||||
" ''' remove a file, do not throw if an error occurs '''\n"
|
" ''' remove a file, do not throw if an error occurs '''\n"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#! /usr/bin/env python
|
#! /usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# file src/tex2lyx/test/runtests.py
|
# file src/tex2lyx/test/runtests.py
|
||||||
@ -161,4 +161,3 @@ def getlyxinput(lyx, lyxfx, lyxf, uselyx2lyx):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv)
|
main(sys.argv)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user