Skip to content

Commit

Permalink
Run isort, flake8, mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
nbes4 committed May 4, 2024
1 parent 342ce14 commit 0f1a62d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions entities/attribute.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import Enum

from entities.common import EnumValue, Value


Expand All @@ -25,7 +26,7 @@ class AttributeType(EnumValue):

def get_name(self) -> str:
return 'type'

def to_unit(self) -> Unit:
if self == AttributeType.VOLTAGE:
return Unit.VOLT
Expand All @@ -44,7 +45,7 @@ def to_unit(self) -> Unit:
else:
return Unit.NONE # Type.STRING and fallback


class MetricPrefix(Enum):
PICO = 'pico'
MICRO = 'micro'
Expand All @@ -53,15 +54,15 @@ class MetricPrefix(Enum):
KILO = 'kilo'
MEGA = 'mega'
GIGA = 'giga'


class AttributeUnit():
def __init__(self, prefix: MetricPrefix, unit: Unit) -> None:
self.attribute_unit = prefix.value + unit.value

def __str__(self) -> str:
return '(unit {})'.format(self.attribute_unit)


class Attribute():
def __init__(self, name: str, value: Value, attribute_type: AttributeType, prefix: MetricPrefix) -> None:
Expand All @@ -71,6 +72,5 @@ def __init__(self, name: str, value: Value, attribute_type: AttributeType, prefi
self.attribute_type = attribute_type if attribute_type is not None else AttributeType.STRING
self.unit = AttributeUnit(self.prefix, self.attribute_type.to_unit())


def __str__(self) -> str:
return '(attribute "{}" {} {} {})'.format(self.name, self.attribute_type, self.unit, self.value)
6 changes: 3 additions & 3 deletions entities/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class Part():
def __init__(self, mpn: str, manufacturer: Manufacturer):
self.mpn = mpn
self.manufacturer = manufacturer
self.attributes = []
self.attributes = [] # type: List[Attribute]

def __str__(self) -> str:
ret = '(part "{}" {}\n'.format(escape_string(self.mpn), self.manufacturer)
ret += indent_entities(self.attributes)
ret += ')'
return ret
def add_attribute(self, attr: Attribute):

def add_attribute(self, attr: Attribute) -> None:
self.attributes.append(attr)


Expand Down

0 comments on commit 0f1a62d

Please sign in to comment.