MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / main

Function main

convert_v3_to_v4.py:129–169  ·  view source on GitHub ↗

the main function when used in cli mode

()

Source from the content-addressed store, hash-verified

127
128
129def main():
130 """the main function when used in cli mode"""
131
132 logger.addHandler(logging.StreamHandler())
133 logger.setLevel(logging.DEBUG)
134
135 parser = argparse.ArgumentParser(description=__doc__)
136 parser.add_argument(
137 "-i",
138 "--in_file",
139 type=argparse.FileType("r"),
140 help="The file to convert from (v3). If absent, reads xml string from stdin.",
141 )
142 parser.add_argument(
143 "-o",
144 "--out_file",
145 nargs="?",
146 type=argparse.FileType("w"),
147 default=sys.stdout,
148 help="The file to write the converted xml (V4)."
149 " Prints to stdout if not specified.",
150 )
151
152 class ArgsType(typing.NamedTuple):
153 """Dummy class to provide type hinting to arguments parsed with argparse"""
154
155 in_file: typing.Optional[typing.TextIO]
156 out_file: typing.TextIO
157
158 args: ArgsType = parser.parse_args()
159
160 if args.in_file is None:
161 if not sys.stdin.isatty():
162 args.in_file = sys.stdin
163 else:
164 logging.error(
165 "The input file was not specified, nor a stdin stream was detected."
166 )
167 sys.exit(1)
168
169 convert_stream(args.in_file, args.out_file)
170
171
172if __name__ == "__main__":

Callers 1

Calls 1

convert_streamFunction · 0.85

Tested by

no test coverage detected