Skip to content

Commit 031f58d

Browse files
committed
Add __main__.py to make python_netlist executable as a module
1 parent e3e3bd5 commit 031f58d

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/python_netlist/__main__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Allow running the module with: python -m python_netlist
5+
"""
6+
import argparse
7+
from pprint import pprint
8+
from .netlist import Netlist
9+
10+
11+
def main():
12+
parser = argparse.ArgumentParser(description='Netlist tool')
13+
parser.add_argument('--out', type=str, help='JSON output file')
14+
parser.add_argument('--no-checks', default=False, action='store_true',
15+
help="Don't perform checks")
16+
parser.add_argument('file', help="Netlist")
17+
args = parser.parse_args()
18+
19+
print("...Parsing " + args.file + "...")
20+
netlist = Netlist(args.file)
21+
if not args.no_checks:
22+
print("###### Check Orphans ######")
23+
orphans = netlist.check_orphans()
24+
if len(orphans):
25+
print("## Possible orphans:")
26+
pprint(orphans)
27+
exit(1)
28+
29+
30+
if __name__ == '__main__':
31+
main()

0 commit comments

Comments
 (0)