Skip to content

Commit

Permalink
Merge pull request #110 from LibrePCB/idc-rework
Browse files Browse the repository at this point in the history
  • Loading branch information
ubruhin authored Aug 30, 2023
2 parents 99df7ca + 3854f84 commit e8558ac
Show file tree
Hide file tree
Showing 4 changed files with 3,811 additions and 3,497 deletions.
25 changes: 24 additions & 1 deletion entities/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

from typing import Iterable, List

from .common import Author, Category, Created, Deprecated, Description, GeneratedBy, Keywords, Name, UUIDValue, Version
from common import escape_string

from .common import (
Author, Category, Created, Deprecated, Description, GeneratedBy, Keywords, Name, StringValue, UUIDValue, Version
)
from .component import SignalUUID
from .helper import indent_entities

Expand All @@ -26,6 +30,20 @@ def __str__(self) -> str:
return '(pad {} {})'.format(self.pad_uuid, self.signal)


class Manufacturer(StringValue):
def __init__(self, manufacturer: str):
super().__init__('manufacturer', manufacturer)


class Part():
def __init__(self, mpn: str, manufacturer: Manufacturer):
self.mpn = mpn
self.manufacturer = manufacturer

def __str__(self) -> str:
return '(part "{}" {}\n)'.format(escape_string(self.mpn), self.manufacturer)


class Device():
def __init__(self, uuid: str, name: Name, description: Description,
keywords: Keywords, author: Author, version: Version,
Expand All @@ -45,11 +63,15 @@ def __init__(self, uuid: str, name: Name, description: Description,
self.component_uuid = component_uuid
self.package_uuid = package_uuid
self.pads = [] # type: List[ComponentPad]
self.parts = [] # type: List[Part]
self.approvals = [] # type: List[str]

def add_pad(self, pad: ComponentPad) -> None:
self.pads.append(pad)

def add_part(self, part: Part) -> None:
self.parts.append(part)

def add_approval(self, approval: str) -> None:
self.approvals.append(approval)

Expand All @@ -67,6 +89,7 @@ def __str__(self) -> str:
' {}\n'.format(self.component_uuid) +\
' {}\n'.format(self.package_uuid)
ret += indent_entities(sorted(self.pads, key=lambda x: str(x.pad_uuid)))
ret += indent_entities(self.parts)
ret += indent_entities(sorted(self.approvals))
ret += ')'
return ret
Expand Down
Loading

0 comments on commit e8558ac

Please sign in to comment.