diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-08-03 15:01:46 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-08-03 15:01:46 -0700 |
commit | 41e1a272e6794feb4d58fed9807d409bd1930c01 (patch) | |
tree | d254831fe61361eb52d1b6176873ca547ef32786 /grc/core | |
parent | e776f1e7196a7543de240b88005b26a02a4c87af (diff) | |
parent | f9dd0a8a347e97e08bc7644f0467e58dcaf1ca66 (diff) |
Merge branch 'next' into python3
Conflicts:
grc/core/Param.py
grc/gui/Application.py
grc/gui/NotebookPage.py
Diffstat (limited to 'grc/core')
-rw-r--r-- | grc/core/Param.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/grc/core/Param.py b/grc/core/Param.py index e8c81383f3..a1e4c782fb 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -54,10 +54,19 @@ class TemplateArg(str): setattr(instance, '_param', param) return instance + def __getitem__(self, item): + return str(self._param.get_opt(item)) if self._param.is_enum() else NotImplemented + def __getattr__(self, item): - param = self._param - attributes = param.options.attributes[param.get_value()] - return str(attributes.get(item)) or NotImplemented + if not self._param.is_enum(): + raise AttributeError() + try: + return str(self._param.get_opt(item)) + except KeyError: + raise AttributeError() + + def __str__(self): + return str(self._param.to_code()) def __call__(self): return self._param.get_evaluated() |