From dc9e9db16047ec589a7b0488fac04c5bb682903c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 26 Aug 2009 13:29:28 -0700 Subject: added rewrite methods to element to separate from validation logic --- grc/python/Block.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'grc/python/Block.py') diff --git a/grc/python/Block.py b/grc/python/Block.py index 47fe13a3c..f47f76446 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -54,7 +54,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 +64,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), -- cgit From cb794a7c8703ea06a9bce110fc1041140f25e8e6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 28 Aug 2009 21:06:19 -0700 Subject: made is_virtual_xxx a block level function, used by port and param classes --- grc/python/Block.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'grc/python/Block.py') diff --git a/grc/python/Block.py b/grc/python/Block.py index f47f76446..2df2049a4 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -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 -- cgit From 152fcbc219cd2e4f6df7b38843844bc85fdf2bc2 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 30 Aug 2009 10:34:10 -0700 Subject: Switched the python classes to inherit from the base and gui classes. Use only **kwargs so all contructor parameters must be passed with keys. Moved gui input forms classes from base to gui param module. --- grc/python/Block.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'grc/python/Block.py') diff --git a/grc/python/Block.py b/grc/python/Block.py index 2df2049a4..dd39b095d 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -18,10 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA """ from .. base.Block import Block as _Block +from .. gui.Block import Block as _GUIBlock import extract_docs import extract_category -class Block(_Block): +class Block(_Block, _GUIBlock): def is_virtual_sink(self): return self.get_key() == 'virtual_sink' def is_virtual_source(self): return self.get_key() == 'virtual_source' @@ -51,6 +52,7 @@ class Block(_Block): flow_graph=flow_graph, n=n, ) + _GUIBlock.__init__(self) def validate(self): """ -- cgit