diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-03-21 11:25:44 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-03-21 11:25:44 -0700 |
commit | ad451c9eee0e6ea9bee981b222cf98aa66a6b52c (patch) | |
tree | d76c11167e1080655617ff52b659c2c658c4fbc0 | |
parent | 6c75cec94a78472b77c0bc3fdd2f1af6b6ab4acb (diff) | |
parent | 80f1bc7840f633822a1032c4ad32ed251742c376 (diff) |
Merge branch 'master' into next
Conflicts:
grc/core/Param.py
-rw-r--r-- | grc/core/Param.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/grc/core/Param.py b/grc/core/Param.py index fd098b76c5..a9a664f74a 100644 --- a/grc/core/Param.py +++ b/grc/core/Param.py @@ -480,13 +480,20 @@ class Param(Element): # Can python use this as a variable? if not _check_id_matcher.match(v): raise Exception('ID "{}" must begin with a letter and may contain letters, numbers, and underscores.'.format(v)) - ids = [param.get_value() for param in self.get_all_params(t)] + ids = [param.get_value() for param in self.get_all_params(t, 'id')] - # Id should only appear once, or zero times if block is disabled - if ids.count(v) > 1: - raise Exception('ID "{}" is not unique.'.format(v)) if v in ID_BLACKLIST: raise Exception('ID "{}" is blacklisted.'.format(v)) + + if self._key == 'id': + # Id should only appear once, or zero times if block is disabled + if ids.count(v) > 1: + raise Exception('ID "{}" is not unique.'.format(v)) + else: + # Id should exist to be a reference + if ids.count(v) < 1: + raise Exception('ID "{}" does not exist.'.format(v)) + return v ######################### @@ -591,17 +598,19 @@ class Param(Element): else: return v - def get_all_params(self, type): + def get_all_params(self, type, key=None): """ - Get all the params from the flowgraph that have the given type. + Get all the params from the flowgraph that have the given type and + optionally a given key Args: type: the specified type + key: the key to match against Returns: a list of params """ - return sum([filter(lambda p: p.get_type() == type, block.get_params()) for block in self.get_parent().get_parent().get_enabled_blocks()], []) + return sum([filter(lambda p: ((p.get_type() == type) and ((key is None) or (p.get_key() == key))), block.get_params()) for block in self.get_parent().get_parent().get_enabled_blocks()], []) def is_enum(self): return self._type == 'enum' |