set_const doesn't need to take in a separate key, can just use the pattern's name
might as well make the convenience function convenient
This commit is contained in:
parent
86315fc32b
commit
566ba99f9c
@ -78,16 +78,15 @@ class DeviceLibrary:
|
|||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return '<DeviceLibrary with keys ' + repr(list(self.generators.keys())) + '>'
|
return '<DeviceLibrary with keys ' + repr(list(self.generators.keys())) + '>'
|
||||||
|
|
||||||
def set_const(self, key: str, const: 'Device') -> None:
|
def set_const(self, const: 'Device') -> None:
|
||||||
"""
|
"""
|
||||||
Convenience function to avoid having to manually wrap
|
Convenience function to avoid having to manually wrap
|
||||||
constant values into callables.
|
already-generated Device objects into callables.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
key: Lookup key, usually the device name
|
const: Pre-generated device object
|
||||||
const: Device object to return
|
|
||||||
"""
|
"""
|
||||||
self.generators[key] = lambda: const
|
self.generators[const.pattern.name] = lambda: const
|
||||||
|
|
||||||
def add(self: L, other: L) -> L:
|
def add(self: L, other: L) -> L:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user