"""
-Copyright 2008 Free Software Foundation, Inc.
+Copyright 2008, 2009 Free Software Foundation, Inc.
This file is part of GNU Radio
GNU Radio Companion is free software; you can redistribute it and/or
"""
from .. base.Port import Port as _Port
-from ... import utils
import Constants
class Port(_Port):
@param n the nested odict
@return a new port
"""
- vlen = utils.exists_or_else(n, 'vlen', '1')
- nports = utils.exists_or_else(n, 'nports', '')
- optional = utils.exists_or_else(n, 'optional', '')
+ vlen = n.find('vlen') or '1'
+ nports = n.find('nports') or ''
+ optional = n.find('optional') or ''
#build the port
_Port.__init__(
self,
self._vlen = vlen
self._optional = bool(optional)
+ def validate(self):
+ _Port.validate(self)
+ try: assert(self.get_enabled_connections() or self.get_optional())
+ except AssertionError: self._add_error_message('Port is not connected.')
+ try: assert(self.is_source() or len(self.get_enabled_connections()) <= 1)
+ except AssertionError: self._add_error_message('Port has too many connections.')
+
def get_vlen(self):
"""
Get the vector length.
}[self.get_type()]
except: return _Port.get_color(self)
- def is_empty(self):
- """
- Is this port empty?
- An empty port has no connections.
- Not empty of optional is set.
- @return true if empty
- """
- return not self.get_optional() and not self.get_connections()
-
class Source(Port):
def __init__(self, block, n):