From 102614dc8fe2f5aefd0fd92c1b6e48107a9629b0 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 12 Dec 2017 12:02:29 +0100 Subject: o Adding a kicad-make-pos tool. --- src/ee/kicad/__init__.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/ee/kicad/__init__.py') diff --git a/src/ee/kicad/__init__.py b/src/ee/kicad/__init__.py index 8d5acd1..1492fc4 100644 --- a/src/ee/kicad/__init__.py +++ b/src/ee/kicad/__init__.py @@ -3,6 +3,7 @@ from typing import Any from ee import EeException from ee.kicad.read_schematic import read_schematic, read_schematics from ee.kicad.to_bom import to_bom, to_bom_xml +from .._utils import run_filters from .model import * __all__ = [ @@ -17,17 +18,20 @@ __all__ = [ "to_pandas", ] +def parse_ref(ref): + m = parse_ref.r.match(ref) + if not m: + return + g = m.groups() +# print("groups={}".format(g)) + return (g[0], None if g[1] == "?" else int(g[1])) + +parse_ref.r = re.compile("([^0-9]+)([0-9]+|\?)$") def to_pandas(obj: Any, **kwarg): import pandas import numpy as np - def run_filter(filters, obj): - for f in filters: - if not f(obj): - return False - return True - def to_pandas_schematics(ss: Schematics): dfs = [to_pandas_schematic(schematic) for schematic in ss.schematics] @@ -65,7 +69,7 @@ def to_pandas(obj: Any, **kwarg): if not include_flg: filters.append(lambda c: c.ref_type != "#FLG") - data = [make_dict(c) for c in components if run_filter(filters, c)] + data = [make_dict(c) for c in components if run_filters(filters, c)] columns = set([key for row in data for key in list(row)]) - set(special_fields) columns = special_fields + list(columns) -- cgit v1.2.3