summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2019-06-19 17:45:04 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-06-30 22:34:23 +0100
commited7379718823b30ae9c85c1000c227fb84b29977 (patch)
tree5a10af7f1442466692ffd0696a1f0c52644ccb41
parent3dc1065b8dccaf3c7a9cde51d9909966dc0ba70d (diff)
downloadpoky-ed7379718823b30ae9c85c1000c227fb84b29977.tar.gz
poky-ed7379718823b30ae9c85c1000c227fb84b29977.tar.bz2
poky-ed7379718823b30ae9c85c1000c227fb84b29977.zip
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: b2c4a3571c9311ee7fca165817ccad6d77ecac7c) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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
olong = "--output="
Elong = "--macro-expand="
-
-this_binary = sys.argv[0].split ("/")[-1]
+this_binary = sys.argv[0].split("/")[-1]
# To be outputted if functionality that hasn't been stubbed yet is invoked.
stub_msg = """
-This stand-in version of %s is not yet fully capable of emulating the real
-version from the GNU texinfo suite. If you see this message, file a bug report
-with details on the recipe that failed.
+This stand-in version of %s is not yet fully capable of emulating
+the real version from the GNU texinfo suite. If you see this message, file a
+bug report with details on the recipe that failed.
""" % this_binary
# Autotools setups query the version, so this is actually necessary. Some of
# them (lookin' at you, glibc) actually look for the substring "GNU texinfo,"
# so we put that substring in there without actually telling a lie.
-version_str = """ %s (fake texinfo, emulating GNU texinfo) 5.2
-
+version_str = """%s (fake texinfo, emulating GNU texinfo) 5.2
+
Super amazing version which is totally not fake in any way whatsoever.
Copyright (C) 2014 Intel Corp. Distributed under the terms of the MIT
license.
@@ -55,62 +54,61 @@ license.
simple_binaries = "pod2texi texi2dvi pdftexi2dvi texindex texi2pdf \
txixml2texi install-info ginstall-info \
- update-info-dir".split ()
+ update-info-dir".split()
# These utilities use a slightly different set of options and flags.
-complex_binaries = "makeinfo texi2any".split ()
+complex_binaries = "makeinfo texi2any".split()
valid_binaries = simple_binaries + complex_binaries
# For generating blank output files.
-def touch_file (path):
- f = open (path, "w")
- f.close ()
+def touch_file(path):
+ with open(path, "w"):
+ pass
assert this_binary in valid_binaries, \
- this_binary + " is not one of " + ', '.join (valid_binaries)
+ this_binary + " is not one of " + ', '.join(valid_binaries)
if "--version" in sys.argv:
print(version_str)
- sys.exit (0)
+ sys.exit(0)
# For debugging
log_interceptions = False
if log_interceptions:
- f = open ("/tmp/intercepted_" + this_binary, "a")
- f.write (' '.join ([this_binary] + sys.argv[1:]) + '\n')
- f.close ()
+ with open("/tmp/intercepted_" + this_binary, "a") as f:
+ f.write(' '.join([this_binary] + sys.argv[1:]) + '\n')
# Look through the options and flags, and if necessary, touch any output
# files.
arg_idx = 1
-while arg_idx < len (sys.argv):
+while arg_idx < len(sys.argv):
arg = sys.argv [arg_idx]
-
+
if arg == "--":
break
-
+
# Something like -I . can result in a need for this (specifically the .)
- elif len (arg) < 2:
+ elif len(arg) < 2:
pass
-
+
# Check if -o or --output is specified. These can be used at most once.
- elif arg[0] == '-' and arg[1] != '-' and arg[len (arg) - 1] == 'o':
- touch_file (sys.argv[arg_idx + 1])
- sys.exit (0)
- elif arg.startswith (olong):
- touch_file (arg.split ("=")[1])
- sys.exit (0)
-
+ elif arg[0] == '-' and arg[1] != '-' and arg[len(arg) - 1] == 'o':
+ touch_file(sys.argv[arg_idx + 1])
+ sys.exit(0)
+ elif arg.startswith(olong):
+ touch_file(arg.split("=")[1])
+ sys.exit(0)
+
# Check for functionality that isn't implemented yet.
else:
assert arg[0] != '-' or arg[1] == '-' or 'E' not in arg or \
this_binary in simple_binaries, \
"-E option not yet supported" + stub_msg
-
- assert not arg.startswith (Elong), \
+
+ assert not arg.startswith(Elong), \
Elong[:-1] + " option not yet supported" + stub_msg
-
+
arg_idx += 1
# The -o/--output option overrides the default. For makeinfo and texi2any,
@@ -119,4 +117,3 @@ while arg_idx < len (sys.argv):
assert this_binary in simple_binaries, \
"Don't know how to get default output file name from input file!" + \
stub_msg
-