]> git.lyx.org Git - features.git/commitdiff
Move all python shebangs from /usr/bin/env to python3.
authorJosé Matos <jamatos@lyx.org>
Sat, 29 Dec 2018 19:14:41 +0000 (19:14 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:54 +0000 (14:39 +0200)
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.

15 files changed:
development/cmake/doc/ReplaceValues.py
development/cmake/po/cat.py
development/cmake/po/unix2dos.py
development/cmake/po/update-gmo.py
development/tools/gen_lfuns.py
development/tools/generate_symbols_images.py
development/tools/generate_symbols_list.py
development/tools/mergepo.py
development/tools/unicodesymbols.py
development/tools/updatedocs.py
development/tools/updatelayouts.py
po/lyx_pot.py
po/postats.py
src/graphics/GraphicsConverter.cpp
src/tex2lyx/test/runtests.py

index da1d42ab9ee9a575e3164501795629ff2a084d16..18eaab377407bd91d60f37f68ba0f3adc18b598f 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 
 from __future__ import print_function
 
index 7a1ee2699b585064522acaeba7198083c9b74d90..0462b29c2f903e37441a28fb3386b16f67728ac5 100644 (file)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 
 from __future__ import print_function
 
index 85af0ecf98f572f534268deb153b9567bc5dabd5..2812873156d6940870db087bae19d7109748ea8b 100644 (file)
@@ -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()
index 8e0c1082b483b8689e0246a5e337977ff277160f..17587559508c0e6404586c5abfd783af5ede3ee8 100644 (file)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 
 ###############
 import sys, os, shutil
index 64dc7dc9a3cf6ed3ea6b824588fc5c9a558378c0..6162bbb3dfca39ea9cea99ec56792d14d07091a0 100755 (executable)
@@ -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)
index 91d685c0a3f72c99d2eac7d6c92871476d5d4365..f3ea8e1d46305730c3a1b45fb40d455db6d6f05d 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file generate_symbols_images.py
index d640a6b72961a01ac531ac05f2cddcb97d6a85d6..5b2963ddab277f761ce94a08547207914378ea30 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file generate_symbols_images.py
index a86b75d844d67b9742f04bffbaf1a9b769e3cf6e..c54448c261d8ad0827d4bbf42d5d04d22768dd76 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file mergepo.py
index 7338d2f0d56570d2d3ec1dd626958fc9c403b34d..b67364baa1da4c6409e82a88656fdd4299ac3fec 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file unciodesymbols.py
index 9101099d4bce3ecdb4a6dbcb2d202a72aa413ca0..41fe091ac47a0f10a4a478af0b8ab62eaf95f785 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 
 # file updatedocs.py
index 67127d695a4bb10c2e113a27a61879be95dc7d05..eaef163d80aa97d75f804028b047284f7f839898 100755 (executable)
@@ -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)
 
index 173d29e8cac573bb5ba5da1856c79a7a2143ee81..5c8502c727279616fa1c3636b96288230475b6b7 100755 (executable)
@@ -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)
-
-
index fe486517c0e7cb1c193b9e43c0f4f3211c2537fc..8c5f058642c87acc01096d3129af73a333a3e78a 100755 (executable)
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/python3
 # -*- coding: utf-8 -*-
 # Copyright (C) 2007 Michael Gerz <michael.gerz@teststep.org>
 # Copyright (C) 2007 José Matos <jamatos@lyx.org>
@@ -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):
index f00f017e2e220e125e3684b0a9f7251b86292d7d..6c3e48d93ad34a2cba1024ccbd829118f831b2d3 100644 (file)
@@ -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"
index 7bfbfe52e936437ed0d63a711d882c10ed19d5b4..0cebef0dabdab583b7c8cfff0fa057c6f3183acb 100755 (executable)
@@ -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)
-