Skip to content

Commit 12c96de

Browse files
authored
Add generator for DIP switches sym & cmp (#152)
1 parent 1b883b8 commit 12c96de

File tree

3 files changed

+1692
-4
lines changed

3 files changed

+1692
-4
lines changed

entities/component.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterable, List
1+
from typing import Iterable, List, Optional
22

33
from common import serialize_common
44

@@ -103,6 +103,7 @@ def __init__(self, signal_uuid: str):
103103

104104

105105
class TextDesignator(EnumValue):
106+
NONE = 'none'
106107
SYMBOL_PIN_NAME = 'pin'
107108
SIGNAL_NAME = 'signal'
108109

@@ -170,12 +171,19 @@ def get_name(self) -> str:
170171

171172

172173
class Variant:
173-
def __init__(self, uuid: str, norm: Norm, name: Name, description: Description, gate: Gate):
174+
def __init__(
175+
self,
176+
uuid: str,
177+
norm: Norm,
178+
name: Name,
179+
description: Description,
180+
gate: Optional[Gate] = None,
181+
):
174182
self.uuid = uuid
175183
self.norm = norm
176184
self.name = name
177185
self.description = description
178-
self.gates = [gate]
186+
self.gates = [gate] if gate else []
179187

180188
def add_gate(self, gate_map: Gate) -> None:
181189
self.gates.append(gate_map)
@@ -186,7 +194,7 @@ def __str__(self) -> str:
186194
+ ' {}\n'.format(self.name)
187195
+ ' {}\n'.format(self.description)
188196
)
189-
ret += indent_entities(sorted(self.gates, key=lambda x: str(x.uuid)))
197+
ret += indent_entities(self.gates)
190198
ret += ')'
191199
return ret
192200

0 commit comments

Comments
 (0)