commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 07/15: grc: adding param templates


From: git
Subject: [Commit-gnuradio] [gnuradio] 07/15: grc: adding param templates
Date: Thu, 10 Apr 2014 19:38:17 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch master
in repository gnuradio.

commit 276c8a1848610d5ac2a2f50996a382cbd83d0dce
Author: Sebastian Koslowski <address@hidden>
Date:   Sat Mar 29 10:22:23 2014 +0100

    grc: adding param templates
---
 grc/base/Block.py    |  4 ++--
 grc/base/Param.py    | 12 ++++++++++--
 grc/python/block.dtd |  3 ++-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/grc/base/Block.py b/grc/base/Block.py
index faa48d9..5a91810 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -23,7 +23,7 @@ from Element import Element
 
 from Cheetah.Template import Template
 from UserDict import UserDict
-
+from itertools import imap
 
 class TemplateArg(UserDict):
     """
@@ -103,7 +103,7 @@ class Block(Element):
                 'hide': 'all',
             })
         ))
-        for param in map(lambda n: 
self.get_parent().get_parent().Param(block=self, n=n), params):
+        for param in imap(lambda n: 
self.get_parent().get_parent().Param(block=self, n=n), params):
             key = param.get_key()
             #test against repeated keys
             if key in self.get_param_keys():
diff --git a/grc/base/Param.py b/grc/base/Param.py
index f8bfe0d..33ba7c3 100644
--- a/grc/base/Param.py
+++ b/grc/base/Param.py
@@ -68,11 +68,19 @@ class Param(Element):
             block: the parent element
             n: the nested odict
         """
-        #grab the data
+        # if the base key is a valid param key, copy its data and overlay this 
params data
+        base_key = n.find('base_key')
+        if base_key and base_key in block.get_param_keys():
+            n_expanded = block.get_param(base_key)._n.copy()
+            n_expanded.update(n)
+            n = n_expanded
+        # save odict in case this param will be base for another
+        self._n = n
+        # parse the data
         self._name = n.find('name')
         self._key = n.find('key')
         value = n.find('value') or ''
-        self._type = n.find('type')
+        self._type = n.find('type') or 'raw'
         self._hide = n.find('hide') or ''
         self._tab_label = n.find('tab') or block.get_param_tab_labels()[0]
         if not self._tab_label in block.get_param_tab_labels():
diff --git a/grc/python/block.dtd b/grc/python/block.dtd
index b37c0ff..18e53fd 100644
--- a/grc/python/block.dtd
+++ b/grc/python/block.dtd
@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 02110-1301, USA
     Sub level elements.
  -->
 <!ELEMENT param_tab_order (tab+)>
-<!ELEMENT param (name, key, value?, type, hide?, option*, tab?)>
+<!ELEMENT param (base_key?, name, key, value?, type?, hide?, option*, tab?)>
 <!ELEMENT option (name, key, opt*)>
 <!ELEMENT sink (name, type, vlen?, nports?, optional?)>
 <!ELEMENT source (name, type, vlen?, nports?, optional?)>
@@ -44,6 +44,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
 02110-1301, USA
 <!ELEMENT grc_source (#PCDATA)>
 <!ELEMENT tab (#PCDATA)>
 <!ELEMENT name (#PCDATA)>
+<!ELEMENT base_key (#PCDATA)>
 <!ELEMENT key (#PCDATA)>
 <!ELEMENT check (#PCDATA)>
 <!ELEMENT bus_sink (#PCDATA)>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]