Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=================
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 --------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
File renamed without changes.
26 changes: 17 additions & 9 deletions src/pyton_netlist/netlist.py → src/python_netlist/netlist.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 = {}
Expand All @@ -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
Expand Down Expand Up @@ -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',
Expand All @@ -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)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down