[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/07: grc: better message port handling fo
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/07: grc: better message port handling for embedded python blocks |
Date: |
Wed, 3 Feb 2016 20:00:59 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch maint
in repository gnuradio.
commit 6947f3afb9ec020d534d3e05b85cb574a41f7232
Author: Sebastian Koslowski <address@hidden>
Date: Fri Jan 29 11:16:57 2016 +0100
grc: better message port handling for embedded python blocks
---
grc/python/Block.py | 7 +++++--
grc/python/epy_block_io.py | 12 +++++-------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/grc/python/Block.py b/grc/python/Block.py
index 239352d..f5c994d 100644
--- a/grc/python/Block.py
+++ b/grc/python/Block.py
@@ -272,7 +272,7 @@ class Block(_Block, _GUIBlock):
self._make = '{}({})'.format(blk_io.cls, ', '.join(
'{0}=${0}'.format(key) for key, _ in blk_io.params))
- params = dict()
+ params = {}
for param in list(self._params):
if hasattr(param, '__epy_param__'):
params[param.get_key()] = param
@@ -293,7 +293,7 @@ class Block(_Block, _GUIBlock):
def update_ports(label, ports, port_specs, direction):
ports_to_remove = list(ports)
iter_ports = iter(ports)
- ports_new = list()
+ ports_new = []
port_current = next(iter_ports, None)
for key, port_type in port_specs:
reuse_port = (
@@ -306,6 +306,9 @@ class Block(_Block, _GUIBlock):
port, port_current = port_current, next(iter_ports, None)
else:
n = odict(dict(name=label + str(key), type=port_type,
key=key))
+ if port_type == 'message':
+ n['name'] = key
+ n['optional'] = '1'
port = platform.Port(block=self, n=n, dir=direction)
ports_new.append(port)
# replace old port list with new one
diff --git a/grc/python/epy_block_io.py b/grc/python/epy_block_io.py
index 8d3ce1c..e089908 100644
--- a/grc/python/epy_block_io.py
+++ b/grc/python/epy_block_io.py
@@ -39,10 +39,8 @@ def _blk_class(source_code):
raise ValueError("Can't interpret source code: " + str(e))
for var in ns.itervalues():
if inspect.isclass(var)and issubclass(var, gr.gateway.gateway_block):
- break
- else:
- raise ValueError('No python block class found in code')
- return var
+ return var
+ raise ValueError('No python block class found in code')
def extract(cls):
@@ -55,7 +53,7 @@ def extract(cls):
cls_name = cls.__name__
if len(defaults) + 1 != len(spec.args):
- raise ValueError("Need all default values")
+ raise ValueError("Need all __init__ arguments to have default values")
try:
instance = cls()
@@ -66,9 +64,9 @@ def extract(cls):
params = list(zip(spec.args[1:], defaults))
sinks = _ports(instance.in_sig(),
- pmt.to_python(instance.message_ports_in()))
+ pmt.to_python(instance.message_ports_in()))
sources = _ports(instance.out_sig(),
- pmt.to_python(instance.message_ports_out()))
+ pmt.to_python(instance.message_ports_out()))
return BlockIO(name, cls_name, params, sinks, sources, doc)
- [Commit-gnuradio] [gnuradio] branch maint updated (11973c6 -> 15b8f49), git, 2016/02/03
- [Commit-gnuradio] [gnuradio] 02/07: grc: escape run command vars for shlex handling (bug #868), git, 2016/02/03
- [Commit-gnuradio] [gnuradio] 07/07: Merge remote-tracking branch 'tom/issue890' into maint, git, 2016/02/03
- [Commit-gnuradio] [gnuradio] 03/07: qtgui: fixes issue #889., git, 2016/02/03
- [Commit-gnuradio] [gnuradio] 01/07: grc: better message port handling for embedded python blocks,
git <=
- [Commit-gnuradio] [gnuradio] 06/07: Merge remote-tracking branch 'tom/issue889' into maint, git, 2016/02/03
- [Commit-gnuradio] [gnuradio] 04/07: digital: addresses issue #890., git, 2016/02/03
- [Commit-gnuradio] [gnuradio] 05/07: gnuradio-runtime/hier_block2: Allow changing of IO sig in the constructor, git, 2016/02/03