diff options
-rw-r--r-- | meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py | 63 |
1 files changed, 30 insertions, 33 deletions
diff --git a/meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py b/meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py index e369f74455..fcc28548af 100644 --- a/meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py +++ b/meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py | |||
@@ -33,21 +33,20 @@ import sys, os | |||
33 | olong = "--output=" | 33 | olong = "--output=" |
34 | Elong = "--macro-expand=" | 34 | Elong = "--macro-expand=" |
35 | 35 | ||
36 | 36 | this_binary = sys.argv[0].split("/")[-1] | |
37 | this_binary = sys.argv[0].split ("/")[-1] | ||
38 | 37 | ||
39 | # To be outputted if functionality that hasn't been stubbed yet is invoked. | 38 | # To be outputted if functionality that hasn't been stubbed yet is invoked. |
40 | stub_msg = """ | 39 | stub_msg = """ |
41 | This stand-in version of %s is not yet fully capable of emulating the real | 40 | This stand-in version of %s is not yet fully capable of emulating |
42 | version from the GNU texinfo suite. If you see this message, file a bug report | 41 | the real version from the GNU texinfo suite. If you see this message, file a |
43 | with details on the recipe that failed. | 42 | bug report with details on the recipe that failed. |
44 | """ % this_binary | 43 | """ % this_binary |
45 | 44 | ||
46 | # Autotools setups query the version, so this is actually necessary. Some of | 45 | # Autotools setups query the version, so this is actually necessary. Some of |
47 | # them (lookin' at you, glibc) actually look for the substring "GNU texinfo," | 46 | # them (lookin' at you, glibc) actually look for the substring "GNU texinfo," |
48 | # so we put that substring in there without actually telling a lie. | 47 | # so we put that substring in there without actually telling a lie. |
49 | version_str = """ %s (fake texinfo, emulating GNU texinfo) 5.2 | 48 | version_str = """%s (fake texinfo, emulating GNU texinfo) 5.2 |
50 | 49 | ||
51 | Super amazing version which is totally not fake in any way whatsoever. | 50 | Super amazing version which is totally not fake in any way whatsoever. |
52 | Copyright (C) 2014 Intel Corp. Distributed under the terms of the MIT | 51 | Copyright (C) 2014 Intel Corp. Distributed under the terms of the MIT |
53 | license. | 52 | license. |
@@ -55,62 +54,61 @@ license. | |||
55 | 54 | ||
56 | simple_binaries = "pod2texi texi2dvi pdftexi2dvi texindex texi2pdf \ | 55 | simple_binaries = "pod2texi texi2dvi pdftexi2dvi texindex texi2pdf \ |
57 | txixml2texi install-info ginstall-info \ | 56 | txixml2texi install-info ginstall-info \ |
58 | update-info-dir".split () | 57 | update-info-dir".split() |
59 | 58 | ||
60 | # These utilities use a slightly different set of options and flags. | 59 | # These utilities use a slightly different set of options and flags. |
61 | complex_binaries = "makeinfo texi2any".split () | 60 | complex_binaries = "makeinfo texi2any".split() |
62 | 61 | ||
63 | valid_binaries = simple_binaries + complex_binaries | 62 | valid_binaries = simple_binaries + complex_binaries |
64 | 63 | ||
65 | # For generating blank output files. | 64 | # For generating blank output files. |
66 | def touch_file (path): | 65 | def touch_file(path): |
67 | f = open (path, "w") | 66 | with open(path, "w"): |
68 | f.close () | 67 | pass |
69 | 68 | ||
70 | assert this_binary in valid_binaries, \ | 69 | assert this_binary in valid_binaries, \ |
71 | this_binary + " is not one of " + ', '.join (valid_binaries) | 70 | this_binary + " is not one of " + ', '.join(valid_binaries) |
72 | 71 | ||
73 | if "--version" in sys.argv: | 72 | if "--version" in sys.argv: |
74 | print(version_str) | 73 | print(version_str) |
75 | sys.exit (0) | 74 | sys.exit(0) |
76 | 75 | ||
77 | # For debugging | 76 | # For debugging |
78 | log_interceptions = False | 77 | log_interceptions = False |
79 | if log_interceptions: | 78 | if log_interceptions: |
80 | f = open ("/tmp/intercepted_" + this_binary, "a") | 79 | with open("/tmp/intercepted_" + this_binary, "a") as f: |
81 | f.write (' '.join ([this_binary] + sys.argv[1:]) + '\n') | 80 | f.write(' '.join([this_binary] + sys.argv[1:]) + '\n') |
82 | f.close () | ||
83 | 81 | ||
84 | # Look through the options and flags, and if necessary, touch any output | 82 | # Look through the options and flags, and if necessary, touch any output |
85 | # files. | 83 | # files. |
86 | arg_idx = 1 | 84 | arg_idx = 1 |
87 | while arg_idx < len (sys.argv): | 85 | while arg_idx < len(sys.argv): |
88 | arg = sys.argv [arg_idx] | 86 | arg = sys.argv [arg_idx] |
89 | 87 | ||
90 | if arg == "--": | 88 | if arg == "--": |
91 | break | 89 | break |
92 | 90 | ||
93 | # Something like -I . can result in a need for this (specifically the .) | 91 | # Something like -I . can result in a need for this (specifically the .) |
94 | elif len (arg) < 2: | 92 | elif len(arg) < 2: |
95 | pass | 93 | pass |
96 | 94 | ||
97 | # Check if -o or --output is specified. These can be used at most once. | 95 | # Check if -o or --output is specified. These can be used at most once. |
98 | elif arg[0] == '-' and arg[1] != '-' and arg[len (arg) - 1] == 'o': | 96 | elif arg[0] == '-' and arg[1] != '-' and arg[len(arg) - 1] == 'o': |
99 | touch_file (sys.argv[arg_idx + 1]) | 97 | touch_file(sys.argv[arg_idx + 1]) |
100 | sys.exit (0) | 98 | sys.exit(0) |
101 | elif arg.startswith (olong): | 99 | elif arg.startswith(olong): |
102 | touch_file (arg.split ("=")[1]) | 100 | touch_file(arg.split("=")[1]) |
103 | sys.exit (0) | 101 | sys.exit(0) |
104 | 102 | ||
105 | # Check for functionality that isn't implemented yet. | 103 | # Check for functionality that isn't implemented yet. |
106 | else: | 104 | else: |
107 | assert arg[0] != '-' or arg[1] == '-' or 'E' not in arg or \ | 105 | assert arg[0] != '-' or arg[1] == '-' or 'E' not in arg or \ |
108 | this_binary in simple_binaries, \ | 106 | this_binary in simple_binaries, \ |
109 | "-E option not yet supported" + stub_msg | 107 | "-E option not yet supported" + stub_msg |
110 | 108 | ||
111 | assert not arg.startswith (Elong), \ | 109 | assert not arg.startswith(Elong), \ |
112 | Elong[:-1] + " option not yet supported" + stub_msg | 110 | Elong[:-1] + " option not yet supported" + stub_msg |
113 | 111 | ||
114 | arg_idx += 1 | 112 | arg_idx += 1 |
115 | 113 | ||
116 | # The -o/--output option overrides the default. For makeinfo and texi2any, | 114 | # The -o/--output option overrides the default. For makeinfo and texi2any, |
@@ -119,4 +117,3 @@ while arg_idx < len (sys.argv): | |||
119 | assert this_binary in simple_binaries, \ | 117 | assert this_binary in simple_binaries, \ |
120 | "Don't know how to get default output file name from input file!" + \ | 118 | "Don't know how to get default output file name from input file!" + \ |
121 | stub_msg | 119 | stub_msg |
122 | |||