aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-09-12 23:25:08 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-09-12 23:25:08 +0200
commit86cf3fcb5eec2c148d60f53cf88b2ca6c3c96552 (patch)
tree4e8094496b04f5405a79b6e0050f10e6e8570b71 /src
parentf81cd8de1bc679786579f14c3da28285789b38e1 (diff)
downloadee-python-86cf3fcb5eec2c148d60f53cf88b2ca6c3c96552.tar.gz
ee-python-86cf3fcb5eec2c148d60f53cf88b2ca6c3c96552.tar.bz2
ee-python-86cf3fcb5eec2c148d60f53cf88b2ca6c3c96552.tar.xz
ee-python-86cf3fcb5eec2c148d60f53cf88b2ca6c3c96552.zip
o Reformat.
Diffstat (limited to 'src')
-rw-r--r--src/ee/kicad/model.py207
1 files changed, 107 insertions, 100 deletions
diff --git a/src/ee/kicad/model.py b/src/ee/kicad/model.py
index 255fad5..f44868b 100644
--- a/src/ee/kicad/model.py
+++ b/src/ee/kicad/model.py
@@ -1,121 +1,128 @@
from typing import List
+
class Position(object):
- def __init__(self, x, y):
- self._x = x
- self._y = y
+ def __init__(self, x, y):
+ self._x = x
+ self._y = y
+
+ @property
+ def x(self):
+ return _x
- @property
- def x(self):
- return _x
+ @property
+ def y(self):
+ return _y
- @property
- def y(self):
- return _y
class ComponentField(object):
- names = ["Reference", "Value", "Footprint", "Datasheet"]
- def __init__(self, index, name, value, position):
- self._index = index
- self._name = name if index >= len(ComponentField.names) else ComponentField.names[index]
- self._value = value
- self._position = position
+ names = ["Reference", "Value", "Footprint", "Datasheet"]
+
+ def __init__(self, index, name, value, position):
+ self._index = index
+ self._name = name if index >= len(ComponentField.names) else ComponentField.names[index]
+ self._value = value
+ self._position = position
+
+ @property
+ def index(self):
+ return self._index
- @property
- def index(self):
- return self._index
+ @property
+ def name(self):
+ return self._name
- @property
- def name(self):
- return self._name
+ @property
+ def value(self):
+ return self._value
- @property
- def value(self):
- return self._value
+ @property
+ def position(self):
+ return self._position
- @property
- def position(self):
- return self._position
class Component(object):
- def __init__(self, position, timestamp, library, name, unit, ref, fields):
- self._position = position
- self._timestamp = timestamp
- self._library = library
- self._name = name
- self._unit = unit
- self._ref = ref
- self._fields = fields # type List[ComponentField]
-
- @property
- def unit(self):
- return self._unit
-
- @property
- def ref(self):
- return self._ref
-
- @property
- def value(self):
- return self._fields[1].value
-
- @property
- def footprint(self):
- return self._fields[2].value
-
- @property
- def fields(self) -> List[ComponentField]:
- return list(self._fields)
-
- @property
- def named_fields(self):
- return [f for f in self._fields if f.name]
+ def __init__(self, position, timestamp, library, name, unit, ref, fields):
+ self._position = position
+ self._timestamp = timestamp
+ self._library = library
+ self._name = name
+ self._unit = unit
+ self._ref = ref
+ self._fields = fields # type List[ComponentField]
+
+ @property
+ def unit(self):
+ return self._unit
+
+ @property
+ def ref(self):
+ return self._ref
+
+ @property
+ def value(self):
+ return self._fields[1].value
+
+ @property
+ def footprint(self):
+ return self._fields[2].value
+
+ @property
+ def fields(self) -> List[ComponentField]:
+ return list(self._fields)
+
+ @property
+ def named_fields(self):
+ return [f for f in self._fields if f.name]
+
class Sheet(object):
- def __init__(self):
- self._components = []
- pass
+ def __init__(self):
+ self._components = []
+ pass
+
+ @property
+ def components(self):
+ return frozenset(self._components)
- @property
- def components(self):
- return frozenset(self._components)
+ def add_component(self, component):
+ self._components.append(component)
- def add_component(self, component):
- self._components.append(component)
class Library(object):
- def __init__(self, name):
- self.name = name
+ def __init__(self, name):
+ self.name = name
+
class Schematic(object):
- def __init__(self):
- self._libraries = set()
- self._sheets = [Sheet()]
- pass
-
- @property
- def first_sheet(self):
- return self._sheets[0]
-
- @property
- def libraries(self):
- return frozenset(self._libraries)
-
- def add_library(self, library):
- self._libraries.add(Library(library))
-
- # Getters
- @property
- def components(self):
- a = []
- for s in self._sheets:
- for c in s.components:
- a.append(c)
- return a
-
- def get_component(self, ref, unit = 1):
- for c in self.components:
- if c.ref == ref and unit == unit:
- return c
-
- raise KeyError("No such component: {}".format(ref))
+ def __init__(self):
+ self._libraries = set()
+ self._sheets = [Sheet()]
+ pass
+
+ @property
+ def first_sheet(self):
+ return self._sheets[0]
+
+ @property
+ def libraries(self):
+ return frozenset(self._libraries)
+
+ def add_library(self, library):
+ self._libraries.add(Library(library))
+
+ # Getters
+ @property
+ def components(self):
+ a = []
+ for s in self._sheets:
+ for c in s.components:
+ a.append(c)
+ return a
+
+ def get_component(self, ref, unit=1):
+ for c in self.components:
+ if c.ref == ref and unit == unit:
+ return c
+
+ raise KeyError("No such component: {}".format(ref))