summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
authorJosh Morman <jmorman@perspectalabs.com>2019-05-27 22:38:39 -0400
committerMartin Braun <martin.braun@ettus.com>2019-05-28 19:32:51 -0700
commitc8ce648df3be9594401587c628cfc7cbb2e2e1c9 (patch)
treee2804de919b7312ac1d596d53bb591a0f2cff8b7 /grc
parentcea8c170bcda208ed802e77ee2fb7cc69eface7a (diff)
grc: function_probe_block extra quotes with block_id
Due to the way stringify_flag is called, the block_id, function_name and function_args are all given extra quotes which cause issues when generating the python source change/add new dtypes for function_probe Fixes #1783
Diffstat (limited to 'grc')
-rw-r--r--grc/blocks/variable_function_probe.block.yml6
-rw-r--r--grc/core/Constants.py2
-rw-r--r--grc/core/params/dtypes.py11
-rw-r--r--grc/core/params/param.py2
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():