MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / _main

Function _main

scripts/embed_python_api.py:26–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25
26def _main():
27 parser = argparse.ArgumentParser()
28
29 parser.add_argument(
30 '--template-script-filepaths', dest='template_script_filepaths', required=True, type=str, nargs='+',
31 help='Path to the template scripts, either absolute or relative to current working directory.')
32
33 parser.add_argument(
34 '--output-dirpath', dest='output_dirpath', required=True, type=str,
35 help='Output directory path, either absolute or relative to the current working directory.')
36
37 args = parser.parse_args()
38
39 if not os.path.isabs(args.output_dirpath):
40 args.output_dirpath = os.path.abspath(args.output_dirpath)
41
42 content = [
43 '// This file is automatically generated by scripts/embed_python_api.py DO NOT EDIT!!!',
44 '',
45 '/*',
46 ' Copyright 2019 Alain Dargelas',
47 ' Licensed under the Apache License, Version 2.0 (the "License");',
48 ' you may not use this file except in compliance with the License.',
49 ' You may obtain a copy of the License at',
50 '',
51 ' http://www.apache.org/licenses/LICENSE-2.0',
52 '',
53 ' Unless required by applicable law or agreed to in writing, software',
54 ' distributed under the License is distributed on an "AS IS" BASIS,',
55 ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
56 ' See the License for the specific language governing permissions and',
57 ' limitations under the License.',
58 ' */',
59 '',
60 '#ifndef SURELOG_SLAPI_SCRIPTS_H',
61 '#define SURELOG_SLAPI_SCRIPTS_H',
62 '#pragma once',
63 '',
64 '#include <string>',
65 '#include <vector>',
66 '',
67 'const std::vector<std::string_view> slapi_scripts = {',
68 ' "import slapi\\n",',
69 ' "\\n",'
70 ]
71
72 for filepath in args.template_script_filepaths:
73 if not os.path.isabs(filepath):
74 filepath = os.path.abspath(filepath)
75
76 with open(filepath, 'rt') as instrm:
77 found_first = False
78 for line in instrm:
79 if not found_first and line.startswith('def SL'):
80 found_first = True
81
82 if found_first:
83 line = line.rstrip()

Callers 1

Calls 2

_write_outputFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected