Skip to content

Commit c8ce648

Browse files
mormjmbr0wn
authored andcommitted
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 gnuradio#1783
1 parent cea8c17 commit c8ce648

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

grc/blocks/variable_function_probe.block.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ flags: [ python ]
55
parameters:
66
- id: block_id
77
label: Block ID
8-
dtype: string
8+
dtype: id
99
default: my_block_0
1010
- id: function_name
1111
label: Function Name
12-
dtype: string
12+
dtype: name
1313
default: get_number
1414
- id: function_args
1515
label: Function Args
16-
dtype: string
16+
dtype: raw
1717
hide: ${ ('none' if function_args else 'part') }
1818
- id: poll_rate
1919
label: Poll Rate (Hz)

grc/core/Constants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
'complex_vector', 'real_vector', 'float_vector', 'int_vector',
6262
'hex', 'string', 'bool',
6363
'file_open', 'file_save', '_multiline', '_multiline_python_external',
64-
'id', 'stream_id',
64+
'id', 'stream_id','name',
6565
'gui_hint',
6666
'import',
6767
}

grc/core/params/dtypes.py

+11
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ def validate_block_id(param):
6868
return value
6969

7070

71+
@validates('name')
72+
def validate_name(param):
73+
# Name of a function that will be generated literally not as a string
74+
value = param.value
75+
# Can python use this as a variable?
76+
if not re.match(r'^[a-z|A-Z]\w*$', value):
77+
raise ValidateError('ID "{}" must begin with a letter and may contain letters, numbers, '
78+
'and underscores.'.format(value))
79+
return value
80+
81+
7182
@validates('stream_id')
7283
def validate_stream_id(param):
7384
value = param.value

grc/core/params/param.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def evaluate(self):
208208
#########################
209209
# ID and Enum types (not evaled)
210210
#########################
211-
if dtype in ('id', 'stream_id') or self.is_enum():
211+
if dtype in ('id', 'stream_id','name') or self.is_enum():
212212
if self.options.attributes:
213213
expr = attributed_str(expr)
214214
for key, value in self.options.attributes[expr].items():

0 commit comments

Comments
 (0)