summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/texinfo-dummy-native
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2019-05-23 20:42:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-05-27 17:06:34 +0100
commitcf5dd9812c3a10f936ae7f48a9d9520994ddffce (patch)
treef84bbd4e2c546618c4f9d88bb1353667440dc68e /meta/recipes-extended/texinfo-dummy-native
parentcdbb7855954d82c865be551ff3dfa5e6abcc306a (diff)
downloadpoky-cf5dd9812c3a10f936ae7f48a9d9520994ddffce.tar.gz
texinfo-dummy-native: A little clean up of template.py
This is mainly whitespace clean up, plus using the with statement when writing files. (From OE-Core rev: f09cb832fa8e83e7e5faf6bd9464481aef5b4547) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended/texinfo-dummy-native')
-rw-r--r--meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py63
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
33olong = "--output=" 33olong = "--output="
34Elong = "--macro-expand=" 34Elong = "--macro-expand="
35 35
36 36this_binary = sys.argv[0].split("/")[-1]
37this_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.
40stub_msg = """ 39stub_msg = """
41This stand-in version of %s is not yet fully capable of emulating the real 40This stand-in version of %s is not yet fully capable of emulating
42version from the GNU texinfo suite. If you see this message, file a bug report 41the real version from the GNU texinfo suite. If you see this message, file a
43with details on the recipe that failed. 42bug 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.
49version_str = """ %s (fake texinfo, emulating GNU texinfo) 5.2 48version_str = """%s (fake texinfo, emulating GNU texinfo) 5.2
50 49
51Super amazing version which is totally not fake in any way whatsoever. 50Super amazing version which is totally not fake in any way whatsoever.
52Copyright (C) 2014 Intel Corp. Distributed under the terms of the MIT 51Copyright (C) 2014 Intel Corp. Distributed under the terms of the MIT
53license. 52license.
@@ -55,62 +54,61 @@ license.
55 54
56simple_binaries = "pod2texi texi2dvi pdftexi2dvi texindex texi2pdf \ 55simple_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.
61complex_binaries = "makeinfo texi2any".split () 60complex_binaries = "makeinfo texi2any".split()
62 61
63valid_binaries = simple_binaries + complex_binaries 62valid_binaries = simple_binaries + complex_binaries
64 63
65# For generating blank output files. 64# For generating blank output files.
66def touch_file (path): 65def touch_file(path):
67 f = open (path, "w") 66 with open(path, "w"):
68 f.close () 67 pass
69 68
70assert this_binary in valid_binaries, \ 69assert 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
73if "--version" in sys.argv: 72if "--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
78log_interceptions = False 77log_interceptions = False
79if log_interceptions: 78if 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.
86arg_idx = 1 84arg_idx = 1
87while arg_idx < len (sys.argv): 85while 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):
119assert this_binary in simple_binaries, \ 117assert 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