summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py55
1 files changed, 18 insertions, 37 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 fcc28548af..86c7c1811a 100644
--- a/meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py
+++ b/meta/recipes-extended/texinfo-dummy-native/texinfo-dummy/template.py
@@ -28,10 +28,8 @@
28# of the executable from argv[0] and emulate the corresponding program, so 28# of the executable from argv[0] and emulate the corresponding program, so
29# multiple copies of this script will exist under different names. 29# multiple copies of this script will exist under different names.
30 30
31import sys, os 31import sys, os, argparse
32 32
33olong = "--output="
34Elong = "--macro-expand="
35 33
36this_binary = sys.argv[0].split("/")[-1] 34this_binary = sys.argv[0].split("/")[-1]
37 35
@@ -61,18 +59,9 @@ complex_binaries = "makeinfo texi2any".split()
61 59
62valid_binaries = simple_binaries + complex_binaries 60valid_binaries = simple_binaries + complex_binaries
63 61
64# For generating blank output files.
65def touch_file(path):
66 with open(path, "w"):
67 pass
68
69assert this_binary in valid_binaries, \ 62assert this_binary in valid_binaries, \
70 this_binary + " is not one of " + ', '.join(valid_binaries) 63 this_binary + " is not one of " + ', '.join(valid_binaries)
71 64
72if "--version" in sys.argv:
73 print(version_str)
74 sys.exit(0)
75
76# For debugging 65# For debugging
77log_interceptions = False 66log_interceptions = False
78if log_interceptions: 67if log_interceptions:
@@ -81,35 +70,27 @@ if log_interceptions:
81 70
82# Look through the options and flags, and if necessary, touch any output 71# Look through the options and flags, and if necessary, touch any output
83# files. 72# files.
84arg_idx = 1 73p = argparse.ArgumentParser()
85while arg_idx < len(sys.argv): 74if this_binary in complex_binaries:
86 arg = sys.argv [arg_idx] 75 p.add_argument('-E', '--macro-expand', metavar='FILE')
87 76p.add_argument('-o', '--output', metavar='DEST')
88 if arg == "--": 77p.add_argument('--version', action='store_true')
89 break
90 78
91 # Something like -I . can result in a need for this (specifically the .) 79args, unknown = p.parse_known_args()
92 elif len(arg) < 2:
93 pass
94
95 # Check if -o or --output is specified. These can be used at most once.
96 elif arg[0] == '-' and arg[1] != '-' and arg[len(arg) - 1] == 'o':
97 touch_file(sys.argv[arg_idx + 1])
98 sys.exit(0)
99 elif arg.startswith(olong):
100 touch_file(arg.split("=")[1])
101 sys.exit(0)
102 80
103 # Check for functionality that isn't implemented yet. 81if args.version:
104 else: 82 print(version_str)
105 assert arg[0] != '-' or arg[1] == '-' or 'E' not in arg or \ 83 sys.exit(0)
106 this_binary in simple_binaries, \
107 "-E option not yet supported" + stub_msg
108 84
109 assert not arg.startswith(Elong), \ 85# Check for functionality that isn't implemented yet.
110 Elong[:-1] + " option not yet supported" + stub_msg 86assert not getattr(args, 'macro_expand', None), \
87 "-E/--macro-expand option not yet supported" + stub_msg
111 88
112 arg_idx += 1 89# Check if -o or --output is specified.
90if args.output:
91 with open(args.output, 'w'):
92 pass
93 sys.exit(0)
113 94
114# The -o/--output option overrides the default. For makeinfo and texi2any, 95# The -o/--output option overrides the default. For makeinfo and texi2any,
115# that default is to look for a @setfilename command in the input file. 96# that default is to look for a @setfilename command in the input file.