diff options
-rw-r--r-- | grc/blocks/variable_function_probe.block.yml | 6 | ||||
-rw-r--r-- | grc/core/Constants.py | 2 | ||||
-rw-r--r-- | grc/core/params/dtypes.py | 11 | ||||
-rw-r--r-- | grc/core/params/param.py | 2 |
4 files changed, 16 insertions, 5 deletions
diff --git a/grc/blocks/variable_function_probe.block.yml b/grc/blocks/variable_function_probe.block.yml index c5b1b972da..cbd3ebc54a 100644 --- a/grc/blocks/variable_function_probe.block.yml +++ b/grc/blocks/variable_function_probe.block.yml @@ -5,15 +5,15 @@ flags: [ python ] parameters: - id: block_id label: Block ID - dtype: string + dtype: id default: my_block_0 - id: function_name label: Function Name - dtype: string + dtype: name default: get_number - id: function_args label: Function Args - dtype: string + dtype: raw hide: ${ ('none' if function_args else 'part') } - id: poll_rate label: Poll Rate (Hz) diff --git a/grc/core/Constants.py b/grc/core/Constants.py index 127e0e05f9..99e6767447 100644 --- a/grc/core/Constants.py +++ b/grc/core/Constants.py @@ -61,7 +61,7 @@ PARAM_TYPE_NAMES = { 'complex_vector', 'real_vector', 'float_vector', 'int_vector', 'hex', 'string', 'bool', 'file_open', 'file_save', '_multiline', '_multiline_python_external', - 'id', 'stream_id', + 'id', 'stream_id','name', 'gui_hint', 'import', } diff --git a/grc/core/params/dtypes.py b/grc/core/params/dtypes.py index 69f7d497dc..7238b8f5c3 100644 --- a/grc/core/params/dtypes.py +++ b/grc/core/params/dtypes.py @@ -68,6 +68,17 @@ def validate_block_id(param): return value +@validates('name') +def validate_name(param): + # Name of a function that will be generated literally not as a string + value = param.value + # Can python use this as a variable? + if not re.match(r'^[a-z|A-Z]\w*$', value): + raise ValidateError('ID "{}" must begin with a letter and may contain letters, numbers, ' + 'and underscores.'.format(value)) + return value + + @validates('stream_id') def validate_stream_id(param): value = param.value diff --git a/grc/core/params/param.py b/grc/core/params/param.py index 3e5d3f2e28..c5b3b8bb1c 100644 --- a/grc/core/params/param.py +++ b/grc/core/params/param.py @@ -208,7 +208,7 @@ class Param(Element): ######################### # ID and Enum types (not evaled) ######################### - if dtype in ('id', 'stream_id') or self.is_enum(): + if dtype in ('id', 'stream_id','name') or self.is_enum(): if self.options.attributes: expr = attributed_str(expr) for key, value in self.options.attributes[expr].items(): |