[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 13/18: grc-refactoring: move template arg t
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 13/18: grc-refactoring: move template arg to param |
Date: |
Sun, 24 Apr 2016 19:19:37 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 2708f33f4531b33c212c60c3cc1fc3d3a92b5ae1
Author: Sebastian Koslowski <address@hidden>
Date: Tue Apr 5 10:15:31 2016 +0200
grc-refactoring: move template arg to param
---
grc/core/Block.py | 25 ++-----------------------
grc/core/Param.py | 24 +++++++++++++++++++++++-
volk | 2 +-
3 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/grc/core/Block.py b/grc/core/Block.py
index d36fe3b..c2c7d4e 100644
--- a/grc/core/Block.py
+++ b/grc/core/Block.py
@@ -34,28 +34,6 @@ from . Element import Element
from . FlowGraph import _variable_matcher
-class TemplateArg(UserDict):
- """
- A cheetah template argument created from a param.
- The str of this class evaluates to the param's to code method.
- The use of this class as a dictionary (enum only) will reveal the enum
opts.
- The __call__ or () method can return the param evaluated to a raw model
data type.
- """
-
- def __init__(self, param):
- UserDict.__init__(self)
- self._param = param
- if param.is_enum():
- for key in param.get_opt_keys():
- self[key] = str(param.get_opt(key))
-
- def __str__(self):
- return str(self._param.to_code())
-
- def __call__(self):
- return self._param.get_evaluated()
-
-
def _get_keys(lst):
return [elem.get_key() for elem in lst]
@@ -714,7 +692,8 @@ class Block(Element):
tmpl = str(tmpl)
if '$' not in tmpl:
return tmpl
- n = dict((p.get_key(), TemplateArg(p)) for p in self.get_params())
+ n = dict((param.get_key(), param.template_arg)
+ for param in self.get_params()) # TODO: cache that
try:
return str(Template(tmpl, n))
except Exception as err:
diff --git a/grc/core/Param.py b/grc/core/Param.py
index 99106de..04c4967 100644
--- a/grc/core/Param.py
+++ b/grc/core/Param.py
@@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
"""
import ast
-
+import weakref
import re
from . import Constants
@@ -121,6 +121,27 @@ class Option(Element):
return self._opts.values()
+class TemplateArg(object):
+ """
+ A cheetah template argument created from a param.
+ The str of this class evaluates to the param's to code method.
+ The use of this class as a dictionary (enum only) will reveal the enum
opts.
+ The __call__ or () method can return the param evaluated to a raw python
data type.
+ """
+
+ def __init__(self, param):
+ self._param = weakref.proxy(param)
+
+ def __getitem__(self, item):
+ return str(self._param.get_opt(item)) if self._param.is_enum() else
NotImplemented
+
+ def __str__(self):
+ return str(self._param.to_code())
+
+ def __call__(self):
+ return self._param.get_evaluated()
+
+
class Param(Element):
is_param = True
@@ -184,6 +205,7 @@ class Param(Element):
self._default = value
self._init = False
self._hostage_cells = list()
+ self.template_arg = TemplateArg(self)
def get_types(self):
return (
diff --git a/volk b/volk
index c2c7f82..c141e93 160000
--- a/volk
+++ b/volk
@@ -1 +1 @@
-Subproject commit c2c7f82aea2ed99df66fad2b91ed29791d7818a5
+Subproject commit c141e937498ee6fb65aff10c14276aa9037a1aad
- [Commit-gnuradio] [gnuradio] branch master updated (bdf8517 -> a03a390), git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 15/18: grc-refactoring: fix gui mode errors, no empty import on fg init, some renames, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 06/18: grc-refactor: rename grc/model/ to grc/core/, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 08/18: grc-refactor: Platform.py fixes, FlowGraphProxy, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 02/18: grc-refactor: clean-up grc directory, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 09/18: grc-refactor: move Messages to core, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 07/18: grc-refactor: cmake fixes and more reorganizing, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 13/18: grc-refactoring: move template arg to param,
git <=
- [Commit-gnuradio] [gnuradio] 14/18: grc-refactor: fix fg load, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 12/18: grc-refactor: remove (hopefully) all deps to GR in core/ and gui/, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 18/18: Merge branch 'maint_grcwg' into refactoring, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 11/18: grc-refactor: move gui prefs to gui, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 05/18: grc-refactor: fixes, type-testing-flags, FlowGraph.py, (more), git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 01/18: grc-refactor: move grc.base to grc.python.base, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 10/18: grc-refactor: Platform.py, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 17/18: grc-refactor: CMake fixes, start-up script cleaned up, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 16/18: Merge remote-tracking branch 'upstream/master' into refactoring, git, 2016/04/24
- [Commit-gnuradio] [gnuradio] 04/18: grc-refactor: Cleaning up code style to match PEP8., git, 2016/04/24