diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2017-09-30 23:10:47 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2017-09-30 23:10:47 +0200 |
commit | dbd1000240535771a45912a18b38ed240a4efa18 (patch) | |
tree | 819291a711ad5bd168c5b366af5f5ca9def14b28 /src/ee/kicad | |
parent | 122850d7a90428b6d7b92fe6100a1f2a6df2a1eb (diff) | |
download | ee-python-dbd1000240535771a45912a18b38ed240a4efa18.tar.gz ee-python-dbd1000240535771a45912a18b38ed240a4efa18.tar.bz2 ee-python-dbd1000240535771a45912a18b38ed240a4efa18.tar.xz ee-python-dbd1000240535771a45912a18b38ed240a4efa18.zip |
o Reformat all.
Diffstat (limited to 'src/ee/kicad')
-rw-r--r-- | src/ee/kicad/__init__.py | 7 | ||||
-rw-r--r-- | src/ee/kicad/bom/__init__.py | 1 | ||||
-rw-r--r-- | src/ee/kicad/bom_tool/__init__.py | 12 | ||||
-rw-r--r-- | src/ee/kicad/model.py | 2 | ||||
-rw-r--r-- | src/ee/kicad/to_bom.py | 3 |
5 files changed, 13 insertions, 12 deletions
diff --git a/src/ee/kicad/__init__.py b/src/ee/kicad/__init__.py index 5187a9c..d2d48da 100644 --- a/src/ee/kicad/__init__.py +++ b/src/ee/kicad/__init__.py @@ -29,6 +29,7 @@ def to_pandas(obj: Any, **kwarg): def to_pandas_schematic(sch: Schematic): # These fields will always be put first. special_fields = ["ref", "ref_type", "ref_num", "value"] + def make_dict(c: Component): fields = { "ref": c.ref, @@ -37,7 +38,7 @@ def to_pandas(obj: Any, **kwarg): "value": c.value, "footprint": c.footprint, } - fields.update({f.name:f.value for f in c.fields if f.is_custom}) + fields.update({f.name: f.value for f in c.fields if f.is_custom}) return fields components = sch.components @@ -56,8 +57,8 @@ def to_pandas(obj: Any, **kwarg): columns = set([key for row in data for key in list(row)]) - set(special_fields) columns = special_fields + list(columns) - return pandas.DataFrame(data=data, columns=columns).\ - set_index("ref").\ + return pandas.DataFrame(data=data, columns=columns). \ + set_index("ref"). \ sort_values(["ref_type", "ref_num"]) if isinstance(obj, Schematic): diff --git a/src/ee/kicad/bom/__init__.py b/src/ee/kicad/bom/__init__.py index a36068b..0392d66 100644 --- a/src/ee/kicad/bom/__init__.py +++ b/src/ee/kicad/bom/__init__.py @@ -97,7 +97,6 @@ class Bom(object): for field in fields: data[field].append(c[field] if field in c else None) - # del data[ref_field_name] data[ref_field_name] = refs data[value_field_name] = values return pandas.DataFrame(data=data, index=refs) diff --git a/src/ee/kicad/bom_tool/__init__.py b/src/ee/kicad/bom_tool/__init__.py index f5d2e4f..3e28eaf 100644 --- a/src/ee/kicad/bom_tool/__init__.py +++ b/src/ee/kicad/bom_tool/__init__.py @@ -103,12 +103,12 @@ def to_panda(bom, bom_settings, csv_format): # type: (Bom, BomSettings, CsvForm # refs.append(functools.reduce(lambda a, b: a + ' ' + b, [c.ref for c in cs], '')) print("group={}".format(gs)) - # return pd.DataFrame(data={ - # 'count': counts, - # 'mpn': mpns, - # 'dpn': dpns, - # 'refs': refs, - # }) + # return pd.DataFrame(data={ + # 'count': counts, + # 'mpn': mpns, + # 'dpn': dpns, + # 'refs': refs, + # }) else: for ref, c in filtered: for key, value in c: diff --git a/src/ee/kicad/model.py b/src/ee/kicad/model.py index a9b0c02..7d9a437 100644 --- a/src/ee/kicad/model.py +++ b/src/ee/kicad/model.py @@ -129,7 +129,7 @@ class Component(object): def get_field(self, name) -> ComponentField: for f in self.fields: if name.lower() == f.name.lower(): - return f + return f class Sheet(object): diff --git a/src/ee/kicad/to_bom.py b/src/ee/kicad/to_bom.py index 9a4f950..62eb075 100644 --- a/src/ee/kicad/to_bom.py +++ b/src/ee/kicad/to_bom.py @@ -1,3 +1,4 @@ +from typing import Iterable from xml.etree.ElementTree import Element from ee.kicad.model import * @@ -34,7 +35,7 @@ def comp(c: Component) -> Element: return comp -def to_bom(schematic: Schematic) -> Component: +def to_bom(schematic: Schematic) -> Iterable[Component]: return [c for c in sorted(schematic.components) if c.ref_type != "#PWR" and c.ref_type != "#FLG"] |