Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __or__(self, obj):
"""Attach a part and another part/pin/net in parallel."""
from .Network import Network
return Network(self) | obj
def __rand__(self, obj):
"""Attach a part and another part/pin/net in serial."""
from .Network import Network
return obj & Network(self)
def create_network(self):
"""Create a network from a list of pins and nets."""
return Network(*self) # An error will occur if list has more than 2 items.
def __ror__(self, obj):
"""Attach a net and another part/pin/net in parallel."""
from .Network import Network
return obj | Network(self)
def __and__(self, obj):
"""Attach a net and another part/pin/net in serial."""
return Network(self) & obj
def __rand__(self, obj):
"""Attach a NetPinList and another part/pin/net in serial."""
return obj & Network(self)
def __rand__(self, obj):
"""Combine two networks by placing them in series. (Reverse-ordered operation.)"""
# Create a network from the first object and then place it in series with the second network.
return Network(obj) & self
def __and__(self, obj):
"""Attach a net and another part/pin/net in serial."""
from .Network import Network
return Network(self) & obj
def __init__(self, *objs):
"""Create a Network object from a list of pins, nets, and parts."""
super(Network, self).__init__()
for obj in objs:
try:
ntwk = obj.create_network() # Create a Network from each object.
except AttributeError:
log_and_raise(
logger,
TypeError,
"Can't create a network from a {} object ({}).".format(
type(obj), obj.__name__
),
)
# Add the in & out ports of the object network to this network.
self.extend(ntwk)
# A Network cannot have more than two ports. But it may have only
def __and__(self, obj):
"""Attach a NetPinList and another part/pin/net in serial."""
return Network(self) & obj