made is_virtual_xxx a block level function, used by port and param classes
[debian/gnuradio] / grc / python / Block.py
index 47fe13a3cc11ee6c87d81d605e5d2e7317eda4c2..2df2049a4d9b8bfa24dac854148cdcd4e6a02691 100644 (file)
@@ -23,6 +23,9 @@ import extract_category
 
 class Block(_Block):
 
+       def is_virtual_sink(self): return self.get_key() == 'virtual_sink'
+       def is_virtual_source(self): return self.get_key() == 'virtual_source'
+
        ##for make source to keep track of indexes
        _source_count = 0
        ##for make sink to keep track of indexes
@@ -54,7 +57,6 @@ class Block(_Block):
                Validate this block.
                Call the base class validate.
                Evaluate the checks: each check must evaluate to True.
-               Adjust the nports.
                """
                _Block.validate(self)
                #evaluate the checks
@@ -65,6 +67,12 @@ class Block(_Block):
                                try: assert check_eval
                                except AssertionError: self.add_error_message('Check "%s" failed.'%check)
                        except: self.add_error_message('Check "%s" did not evaluate.'%check)
+
+       def rewrite(self):
+               """
+               Add and remove ports to adjust for the nports.
+               """
+               _Block.rewrite(self)
                #adjust nports
                for get_ports, get_port in (
                        (self.get_sources, self.get_source),