diff --git a/README.rst b/README.rst index f3c98e1..ae86780 100644 --- a/README.rst +++ b/README.rst @@ -80,7 +80,7 @@ Automatic Checks Common Schematic capture mistakes can be caught analyzing the Netlist. The most common is probably unconnected pins due to a bad net label. -`check_orphands` lists all nets that have (by default) less than 2 connections. +`check_orphans` lists all nets that have (by default) less than 2 connections. Command-line tool ================= diff --git a/docs/conf.py b/docs/conf.py index fb6d121..e4e30d4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -35,7 +35,7 @@ from sphinx import apidoc output_dir = os.path.join(__location__, "api") -module_dir = os.path.join(__location__, "../src/pyton_netlist") +module_dir = os.path.join(__location__, "../src/python_netlist") try: shutil.rmtree(output_dir) except FileNotFoundError: @@ -216,7 +216,7 @@ # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'pyton_netlist-doc' +htmlhelp_basename = 'python_netlist-doc' # -- Options for LaTeX output -------------------------------------------------- diff --git a/setup.cfg b/setup.cfg index 4748d30..a976330 100644 --- a/setup.cfg +++ b/setup.cfg @@ -53,10 +53,10 @@ testing = [options.entry_points] # Add here console scripts like: # console_scripts = -# script_name = pyton_netlist.module:function +# script_name = python_netlist.module:function # For example: # console_scripts = -# fibonacci = pyton_netlist.skeleton:run +# fibonacci = python_netlist.skeleton:run # And any other entry points, for example: # pyscaffold.cli = # awesome = pyscaffoldext.awesome.extension:AwesomeExtension diff --git a/setup.py b/setup.py index ace7c92..d864eb3 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ - Setup file for pyton_netlist. + Setup file for python_netlist. Use setup.cfg to configure your project. This file was generated with PyScaffold 3.2.3. diff --git a/src/pyton_netlist/__init__.py b/src/python_netlist/__init__.py similarity index 100% rename from src/pyton_netlist/__init__.py rename to src/python_netlist/__init__.py diff --git a/src/pyton_netlist/netlist.py b/src/python_netlist/netlist.py old mode 100644 new mode 100755 similarity index 85% rename from src/pyton_netlist/netlist.py rename to src/python_netlist/netlist.py index b688c73..8a8fcd8 --- a/src/pyton_netlist/netlist.py +++ b/src/python_netlist/netlist.py @@ -1,12 +1,15 @@ +#!/usr/bin/env python3 # Copyright 2020 Railnova SA # Author: Charles-Henri Mousset # # Netlist parsing for filling platform ios from pprint import pprint + class Netlist: """A netlist is a dict of all the nets (signals) on a PCB, and of all its connections to the different components of that board.""" + def __init__(self, path): self.path = path netlist = {} @@ -27,7 +30,7 @@ def __init__(self, path): while len(txt[i]) > 4: l = txt[i].strip() tok = l.split() - net_conns.update({tok[0] : tok[1]}) + net_conns.update({tok[0]: tok[1]}) i += 1 netlist.update({net_name: net_conns}) i += 1 @@ -59,13 +62,16 @@ def find_pins(self, nets, con_to_pin, ignore_missing=False): raise Exception("net {} has no associated pin!".format(n)) return " ".join(balls) - def check_orphands(self, min_pins=2): + def check_orphans(self, min_pins=2): """return a list of nets that have less than min_pins connections""" netlist = self.netlist - return {n: netlist[n] for n in netlist if len(netlist[n]) < min_pins and not (n.startswith('NC_') or ('.NC_' in n))} + return {n: netlist[n] for n in netlist if + len(netlist[n]) < min_pins and not (n.startswith('NC_') or ('.NC_' in n))} + if __name__ == '__main__': import argparse + parser = argparse.ArgumentParser(description='Netlist tool') parser.add_argument('--out', type=str, help='JSON output file') parser.add_argument('--no-checks', default=False, action='store_true', @@ -76,15 +82,17 @@ def check_orphands(self, min_pins=2): print("...Parsing " + args.file + "...") netlist = Netlist(args.file) if not args.no_checks: - print("###### Check Orphands ######") - orphands = netlist.check_orphands() - if len(orphands): - print("## Possible orphands:") - pprint(orphands) + print("###### Check Orphans ######") + orphans = netlist.check_orphans() + if len(orphans): + print("## Possible orphans:") + pprint(orphans) + exit(1) else: - print("No orphands: OK") + print("No orphans: OK") if args.out: import json + with open(args.out, 'w') as f: json.dump(netlist.netlist, f) diff --git a/tests/conftest.py b/tests/conftest.py index 5a9e8e0..a5a50d9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ - Dummy conftest.py for pyton_netlist. + Dummy conftest.py for python_netlist. If you don't know what this is for, just leave it empty. Read more about conftest.py under: