From b0dca7fa15b3687124633490a6f5ec35d7812f93 Mon Sep 17 00:00:00 2001 From: Horea Christian Date: Mon, 25 Jul 2022 13:10:55 -0400 Subject: [PATCH 1/3] Using label string as in contemporary schema --- .../data/expected_bids_validator_xs_write.log | 2 +- .../bidsschematools/tests/test_validator.py | 74 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log b/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log index e8daa55375..b1383227f3 100644 --- a/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log +++ b/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log @@ -1,7 +1,7 @@ SUMMARY: 0 out of 1 files were successfully validated, using the following regular expressions: - - `.*?/sub-(?P([a-zA-Z0-9]*?))/(|ses-(?P([a-zA-Z0-9]*?))/)anat/sub-(?P=subject)(|_ses-(?P=session))(|_acq-(?P([a-zA-Z0-9]*?)))(|_ce-(?P([a-zA-Z0-9]*?)))(|_rec-(?P([a-zA-Z0-9]*?)))(|_run-(?P([a-zA-Z0-9]*?)))(|_part-(?P(mag|phase|real|imag)))_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)\.(nii.gz|nii|json)$` + - `.*?/sub-(?P([0-9a-zA-Z]+))/(|ses-(?P([0-9a-zA-Z]+))/)anat/sub-(?P=subject)(|_ses-(?P=session))(|_acq-(?P([0-9a-zA-Z]+)))(|_ce-(?P([0-9a-zA-Z]+)))(|_rec-(?P([0-9a-zA-Z]+)))(|_run-(?P([0-9a-zA-Z]+)))(|_part-(?P(mag|phase|real|imag)))_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)\.(nii.gz|nii|json)$` The following files were not matched by any regex schema entry: * `/home/chymera/.data2/datalad/000026/rawdata/sub-EXC022/anat/sub-EXC022_ses-MRI_flip-1_VFA.nii.gz The following mandatory regex schema entries did not match any files: diff --git a/tools/schemacode/bidsschematools/tests/test_validator.py b/tools/schemacode/bidsschematools/tests/test_validator.py index 179a027ff3..cdbc416d5f 100644 --- a/tools/schemacode/bidsschematools/tests/test_validator.py +++ b/tools/schemacode/bidsschematools/tests/test_validator.py @@ -11,7 +11,7 @@ def test__add_entity(): regex_entities = "" entity = "subject" entity_shorthand = "sub" - variable_field = "([a-zA-Z0-9]*?)" + variable_field = "([0-9a-zA-Z]+)" requirement_level = "required" _regex_entities = _add_entity( @@ -27,13 +27,13 @@ def test__add_entity(): # Test append input and optional entity regex_entities = ( "sub-(?P=subject)(|_ses-(?P=session))" - "(|_task-(?P([a-zA-Z0-9]*?)))(|_trc-(?P([a-zA-Z0-9]*?)))" - "(|_rec-(?P([a-zA-Z0-9]*?)))" - "(|_run-(?P([a-zA-Z0-9]*?)))" + "(|_task-(?P([0-9a-zA-Z]+)))(|_trc-(?P([0-9a-zA-Z]+)))" + "(|_rec-(?P([0-9a-zA-Z]+)))" + "(|_run-(?P([0-9a-zA-Z]+)))" ) entity = "recording" entity_shorthand = "recording" - variable_field = "([a-zA-Z0-9]*?)" + variable_field = "([0-9a-zA-Z]+)" requirement_level = "optional" _regex_entities = _add_entity( @@ -46,10 +46,10 @@ def test__add_entity(): assert ( _regex_entities == "sub-(?P=subject)(|_ses-(?P=session))" - "(|_task-(?P([a-zA-Z0-9]*?)))(|_trc-(?P([a-zA-Z0-9]*?)))" - "(|_rec-(?P([a-zA-Z0-9]*?)))" - "(|_run-(?P([a-zA-Z0-9]*?)))" - "(|_recording-(?P([a-zA-Z0-9]*?)))" + "(|_task-(?P([0-9a-zA-Z]+)))(|_trc-(?P([0-9a-zA-Z]+)))" + "(|_rec-(?P([0-9a-zA-Z]+)))" + "(|_run-(?P([0-9a-zA-Z]+)))" + "(|_recording-(?P([0-9a-zA-Z]+)))" ) @@ -59,8 +59,8 @@ def test__add_extensions(): # Test single extension regex_string = ( "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([a-zA-Z0-9]*?))" - "(|_acq-(?P([a-zA-Z0-9]*?)))_photo" + "_sample-(?P([0-9a-zA-Z]+))" + "(|_acq-(?P([0-9a-zA-Z]+)))_photo" ) variant = { "suffixes": ["photo"], @@ -76,15 +76,15 @@ def test__add_extensions(): assert ( _regex_string == "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([a-zA-Z0-9]*?))" - "(|_acq-(?P([a-zA-Z0-9]*?)))_photo\\.jpg" + "_sample-(?P([0-9a-zA-Z]+))" + "(|_acq-(?P([0-9a-zA-Z]+)))_photo\\.jpg" ) # Test multiple extensions regex_string = ( "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([a-zA-Z0-9]*?))" - "(|_acq-(?P([a-zA-Z0-9]*?)))_photo" + "_sample-(?P([0-9a-zA-Z]+))" + "(|_acq-(?P([0-9a-zA-Z]+)))_photo" ) variant = { "suffixes": ["photo"], @@ -100,8 +100,8 @@ def test__add_extensions(): assert ( _regex_string == "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([a-zA-Z0-9]*?))" - "(|_acq-(?P([a-zA-Z0-9]*?)))" + "_sample-(?P([0-9a-zA-Z]+))" + "(|_acq-(?P([0-9a-zA-Z]+)))" "_photo(\\.jpg|\\.png|\\.tif)" ) @@ -186,10 +186,10 @@ def test__add_suffixes(): # Test multiple expansions regex_entities = ( "sub-(?P=subject)(|_ses-(?P=session))" - "(|_acq-(?P([a-zA-Z0-9]*?)))" - "(|_rec-(?P([a-zA-Z0-9]*?)))" - "(|_dir-(?P([a-zA-Z0-9]*?)))(|_run-(?P([a-zA-Z0-9]*?)))" - "(|_recording-(?P([a-zA-Z0-9]*?)))" + "(|_acq-(?P([0-9a-zA-Z]+)))" + "(|_rec-(?P([0-9a-zA-Z]+)))" + "(|_dir-(?P([0-9a-zA-Z]+)))(|_run-(?P([0-9a-zA-Z]+)))" + "(|_recording-(?P([0-9a-zA-Z]+)))" ) variant = { "suffixes": [ @@ -212,10 +212,10 @@ def test__add_suffixes(): } regex_string = ( "sub-(?P=subject)(|_ses-(?P=session))" - "(|_acq-(?P([a-zA-Z0-9]*?)))" - "(|_rec-(?P([a-zA-Z0-9]*?)))" - "(|_dir-(?P([a-zA-Z0-9]*?)))(|_run-(?P([a-zA-Z0-9]*?)))" - "(|_recording-(?P([a-zA-Z0-9]*?)))" + "(|_acq-(?P([0-9a-zA-Z]+)))" + "(|_rec-(?P([0-9a-zA-Z]+)))" + "(|_dir-(?P([0-9a-zA-Z]+)))(|_run-(?P([0-9a-zA-Z]+)))" + "(|_recording-(?P([0-9a-zA-Z]+)))" "_(physio|stim)" ) @@ -247,12 +247,12 @@ def test_write_report(tmp_path): validation_result["schema_tracking"] = [ { - "regex": ".*?/sub-(?P([a-zA-Z0-9]*?))/" - "(|ses-(?P([a-zA-Z0-9]*?))/)anat/sub-(?P=subject)" - "(|_ses-(?P=session))(|_acq-(?P([a-zA-Z0-9]*?)))" - "(|_ce-(?P([a-zA-Z0-9]*?)))" - "(|_rec-(?P([a-zA-Z0-9]*?)))" - "(|_run-(?P([a-zA-Z0-9]*?)))" + "regex": ".*?/sub-(?P([0-9a-zA-Z]+))/" + "(|ses-(?P([0-9a-zA-Z]+))/)anat/sub-(?P=subject)" + "(|_ses-(?P=session))(|_acq-(?P([0-9a-zA-Z]+)))" + "(|_ce-(?P([0-9a-zA-Z]+)))" + "(|_rec-(?P([0-9a-zA-Z]+)))" + "(|_run-(?P([0-9a-zA-Z]+)))" "(|_part-(?P(mag|phase|real|imag)))" "_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)" "\\.(nii.gz|nii|json)$", @@ -261,12 +261,12 @@ def test_write_report(tmp_path): ] validation_result["schema_listing"] = [ { - "regex": ".*?/sub-(?P([a-zA-Z0-9]*?))/" - "(|ses-(?P([a-zA-Z0-9]*?))/)anat/sub-(?P=subject)" - "(|_ses-(?P=session))(|_acq-(?P([a-zA-Z0-9]*?)))" - "(|_ce-(?P([a-zA-Z0-9]*?)))" - "(|_rec-(?P([a-zA-Z0-9]*?)))" - "(|_run-(?P([a-zA-Z0-9]*?)))" + "regex": ".*?/sub-(?P([0-9a-zA-Z]+))/" + "(|ses-(?P([0-9a-zA-Z]+))/)anat/sub-(?P=subject)" + "(|_ses-(?P=session))(|_acq-(?P([0-9a-zA-Z]+)))" + "(|_ce-(?P([0-9a-zA-Z]+)))" + "(|_rec-(?P([0-9a-zA-Z]+)))" + "(|_run-(?P([0-9a-zA-Z]+)))" "(|_part-(?P(mag|phase|real|imag)))" "_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)" "\\.(nii.gz|nii|json)$", From f57d234f70b727dec4a872da04e1960294a6cc98 Mon Sep 17 00:00:00 2001 From: Horea Christian Date: Tue, 26 Jul 2022 13:13:03 -0400 Subject: [PATCH 2/3] Dropped unneeded capture groups --- .../data/expected_bids_validator_xs_write.log | 2 +- .../bidsschematools/tests/test_validator.py | 76 +++++++++---------- tools/schemacode/bidsschematools/validator.py | 8 +- 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log b/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log index b1383227f3..4d410c3cc8 100644 --- a/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log +++ b/tools/schemacode/bidsschematools/tests/data/expected_bids_validator_xs_write.log @@ -1,7 +1,7 @@ SUMMARY: 0 out of 1 files were successfully validated, using the following regular expressions: - - `.*?/sub-(?P([0-9a-zA-Z]+))/(|ses-(?P([0-9a-zA-Z]+))/)anat/sub-(?P=subject)(|_ses-(?P=session))(|_acq-(?P([0-9a-zA-Z]+)))(|_ce-(?P([0-9a-zA-Z]+)))(|_rec-(?P([0-9a-zA-Z]+)))(|_run-(?P([0-9a-zA-Z]+)))(|_part-(?P(mag|phase|real|imag)))_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)\.(nii.gz|nii|json)$` + - `.*?/sub-(?P[0-9a-zA-Z]+)/(|ses-(?P[0-9a-zA-Z]+)/)anat/sub-(?P=subject)(|_ses-(?P=session))(|_acq-(?P[0-9a-zA-Z]+))(|_ce-(?P[0-9a-zA-Z]+))(|_rec-(?P[0-9a-zA-Z]+))(|_run-(?P[0-9a-zA-Z]+))(|_part-(?P(mag|phase|real|imag)))_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)\.(nii.gz|nii|json)$` The following files were not matched by any regex schema entry: * `/home/chymera/.data2/datalad/000026/rawdata/sub-EXC022/anat/sub-EXC022_ses-MRI_flip-1_VFA.nii.gz The following mandatory regex schema entries did not match any files: diff --git a/tools/schemacode/bidsschematools/tests/test_validator.py b/tools/schemacode/bidsschematools/tests/test_validator.py index cdbc416d5f..ef54ece79e 100644 --- a/tools/schemacode/bidsschematools/tests/test_validator.py +++ b/tools/schemacode/bidsschematools/tests/test_validator.py @@ -11,7 +11,7 @@ def test__add_entity(): regex_entities = "" entity = "subject" entity_shorthand = "sub" - variable_field = "([0-9a-zA-Z]+)" + variable_field = "[0-9a-zA-Z]+" requirement_level = "required" _regex_entities = _add_entity( @@ -27,13 +27,13 @@ def test__add_entity(): # Test append input and optional entity regex_entities = ( "sub-(?P=subject)(|_ses-(?P=session))" - "(|_task-(?P([0-9a-zA-Z]+)))(|_trc-(?P([0-9a-zA-Z]+)))" - "(|_rec-(?P([0-9a-zA-Z]+)))" - "(|_run-(?P([0-9a-zA-Z]+)))" + "(|_task-(?P[0-9a-zA-Z]+))(|_trc-(?P[0-9a-zA-Z]+))" + "(|_rec-(?P[0-9a-zA-Z]+))" + "(|_run-(?P[0-9a-zA-Z]+))" ) entity = "recording" entity_shorthand = "recording" - variable_field = "([0-9a-zA-Z]+)" + variable_field = "[0-9a-zA-Z]+" requirement_level = "optional" _regex_entities = _add_entity( @@ -46,10 +46,10 @@ def test__add_entity(): assert ( _regex_entities == "sub-(?P=subject)(|_ses-(?P=session))" - "(|_task-(?P([0-9a-zA-Z]+)))(|_trc-(?P([0-9a-zA-Z]+)))" - "(|_rec-(?P([0-9a-zA-Z]+)))" - "(|_run-(?P([0-9a-zA-Z]+)))" - "(|_recording-(?P([0-9a-zA-Z]+)))" + "(|_task-(?P[0-9a-zA-Z]+))(|_trc-(?P[0-9a-zA-Z]+))" + "(|_rec-(?P[0-9a-zA-Z]+))" + "(|_run-(?P[0-9a-zA-Z]+))" + "(|_recording-(?P[0-9a-zA-Z]+))" ) @@ -59,8 +59,8 @@ def test__add_extensions(): # Test single extension regex_string = ( "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([0-9a-zA-Z]+))" - "(|_acq-(?P([0-9a-zA-Z]+)))_photo" + "_sample-(?P[0-9a-zA-Z]+)" + "(|_acq-(?P[0-9a-zA-Z]+))_photo" ) variant = { "suffixes": ["photo"], @@ -76,15 +76,15 @@ def test__add_extensions(): assert ( _regex_string == "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([0-9a-zA-Z]+))" - "(|_acq-(?P([0-9a-zA-Z]+)))_photo\\.jpg" + "_sample-(?P[0-9a-zA-Z]+)" + "(|_acq-(?P[0-9a-zA-Z]+))_photo\\.jpg" ) # Test multiple extensions regex_string = ( "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([0-9a-zA-Z]+))" - "(|_acq-(?P([0-9a-zA-Z]+)))_photo" + "_sample-(?P[0-9a-zA-Z]+)" + "(|_acq-(?P[0-9a-zA-Z]+))_photo" ) variant = { "suffixes": ["photo"], @@ -100,8 +100,8 @@ def test__add_extensions(): assert ( _regex_string == "sub-(?P=subject)(|_ses-(?P=session))" - "_sample-(?P([0-9a-zA-Z]+))" - "(|_acq-(?P([0-9a-zA-Z]+)))" + "_sample-(?P[0-9a-zA-Z]+)" + "(|_acq-(?P[0-9a-zA-Z]+))" "_photo(\\.jpg|\\.png|\\.tif)" ) @@ -159,7 +159,7 @@ def test__add_subdirs(): ) assert ( - _regex_string == "/sub-(?P([0-9a-zA-Z]+))/sub-(?P=subject)" + _regex_string == "/sub-(?P[0-9a-zA-Z]+)/sub-(?P=subject)" "_sessions\\.(tsv|json)" ) @@ -186,10 +186,10 @@ def test__add_suffixes(): # Test multiple expansions regex_entities = ( "sub-(?P=subject)(|_ses-(?P=session))" - "(|_acq-(?P([0-9a-zA-Z]+)))" - "(|_rec-(?P([0-9a-zA-Z]+)))" - "(|_dir-(?P([0-9a-zA-Z]+)))(|_run-(?P([0-9a-zA-Z]+)))" - "(|_recording-(?P([0-9a-zA-Z]+)))" + "(|_acq-(?P[0-9a-zA-Z]+))" + "(|_rec-(?P[0-9a-zA-Z]+))" + "(|_dir-(?P[0-9a-zA-Z]+))(|_run-(?P[0-9a-zA-Z]+))" + "(|_recording-(?P[0-9a-zA-Z]+))" ) variant = { "suffixes": [ @@ -212,10 +212,10 @@ def test__add_suffixes(): } regex_string = ( "sub-(?P=subject)(|_ses-(?P=session))" - "(|_acq-(?P([0-9a-zA-Z]+)))" - "(|_rec-(?P([0-9a-zA-Z]+)))" - "(|_dir-(?P([0-9a-zA-Z]+)))(|_run-(?P([0-9a-zA-Z]+)))" - "(|_recording-(?P([0-9a-zA-Z]+)))" + "(|_acq-(?P[0-9a-zA-Z]+))" + "(|_rec-(?P[0-9a-zA-Z]+))" + "(|_dir-(?P[0-9a-zA-Z]+))(|_run-(?P[0-9a-zA-Z]+))" + "(|_recording-(?P[0-9a-zA-Z]+))" "_(physio|stim)" ) @@ -247,12 +247,12 @@ def test_write_report(tmp_path): validation_result["schema_tracking"] = [ { - "regex": ".*?/sub-(?P([0-9a-zA-Z]+))/" - "(|ses-(?P([0-9a-zA-Z]+))/)anat/sub-(?P=subject)" - "(|_ses-(?P=session))(|_acq-(?P([0-9a-zA-Z]+)))" - "(|_ce-(?P([0-9a-zA-Z]+)))" - "(|_rec-(?P([0-9a-zA-Z]+)))" - "(|_run-(?P([0-9a-zA-Z]+)))" + "regex": ".*?/sub-(?P[0-9a-zA-Z]+)/" + "(|ses-(?P[0-9a-zA-Z]+)/)anat/sub-(?P=subject)" + "(|_ses-(?P=session))(|_acq-(?P[0-9a-zA-Z]+))" + "(|_ce-(?P[0-9a-zA-Z]+))" + "(|_rec-(?P[0-9a-zA-Z]+))" + "(|_run-(?P[0-9a-zA-Z]+))" "(|_part-(?P(mag|phase|real|imag)))" "_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)" "\\.(nii.gz|nii|json)$", @@ -261,12 +261,12 @@ def test_write_report(tmp_path): ] validation_result["schema_listing"] = [ { - "regex": ".*?/sub-(?P([0-9a-zA-Z]+))/" - "(|ses-(?P([0-9a-zA-Z]+))/)anat/sub-(?P=subject)" - "(|_ses-(?P=session))(|_acq-(?P([0-9a-zA-Z]+)))" - "(|_ce-(?P([0-9a-zA-Z]+)))" - "(|_rec-(?P([0-9a-zA-Z]+)))" - "(|_run-(?P([0-9a-zA-Z]+)))" + "regex": ".*?/sub-(?P[0-9a-zA-Z]+)/" + "(|ses-(?P[0-9a-zA-Z]+)/)anat/sub-(?P=subject)" + "(|_ses-(?P=session))(|_acq-(?P[0-9a-zA-Z]+))" + "(|_ce-(?P[0-9a-zA-Z]+))" + "(|_rec-(?P[0-9a-zA-Z]+))" + "(|_run-(?P[0-9a-zA-Z]+))" "(|_part-(?P(mag|phase|real|imag)))" "_(T1w|T2w|PDw|T2starw|FLAIR|inplaneT1|inplaneT2|PDT2|angio|T2star)" "\\.(nii.gz|nii|json)$", diff --git a/tools/schemacode/bidsschematools/validator.py b/tools/schemacode/bidsschematools/validator.py index 45ebc97387..c91cbac86c 100644 --- a/tools/schemacode/bidsschematools/validator.py +++ b/tools/schemacode/bidsschematools/validator.py @@ -168,7 +168,7 @@ def _add_subdirs(regex_string, variant, datatype, entity_definitions, formats, m for dir_entity in DIR_ENTITIES: if dir_entity in variant["entities"].keys(): format_selection = formats[entity_definitions[dir_entity]["format"]] - variable_field = f"({format_selection['pattern']})" + variable_field = format_selection['pattern'] shorthand = entity_definitions[dir_entity]["name"] if variant["entities"][dir_entity] == "required": regex_subdir = f"{shorthand}-(?P<{dir_entity}>{variable_field})/" @@ -294,12 +294,10 @@ def load_entities( if "enum" in entity_definitions[entity].keys(): # Entity key-value pattern with specific allowed values # tested, works! - variable_field = "({})".format( - "|".join(entity_definitions[entity]["enum"]), - ) + variable_field = "|".join(entity_definitions[entity]["enum"]) else: format_selection = formats[entity_definitions[entity]["format"]] - variable_field = f"({format_selection['pattern']})" + variable_field = format_selection['pattern'] regex_entities = _add_entity( regex_entities, entity, From baa2a89eeff24a423aaf3b031e3ac04466a0d851 Mon Sep 17 00:00:00 2001 From: Horea Christian Date: Tue, 26 Jul 2022 13:15:51 -0400 Subject: [PATCH 3/3] syntax fixes --- tools/schemacode/bidsschematools/tests/test_validator.py | 5 +---- tools/schemacode/bidsschematools/validator.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/schemacode/bidsschematools/tests/test_validator.py b/tools/schemacode/bidsschematools/tests/test_validator.py index ef54ece79e..000147154c 100644 --- a/tools/schemacode/bidsschematools/tests/test_validator.py +++ b/tools/schemacode/bidsschematools/tests/test_validator.py @@ -158,10 +158,7 @@ def test__add_subdirs(): regex_string, variant, datatype, entity_definitions, formats, modality_datatypes ) - assert ( - _regex_string == "/sub-(?P[0-9a-zA-Z]+)/sub-(?P=subject)" - "_sessions\\.(tsv|json)" - ) + assert _regex_string == "/sub-(?P[0-9a-zA-Z]+)/sub-(?P=subject)_sessions\\.(tsv|json)" def test__add_suffixes(): diff --git a/tools/schemacode/bidsschematools/validator.py b/tools/schemacode/bidsschematools/validator.py index c91cbac86c..45c057f5d9 100644 --- a/tools/schemacode/bidsschematools/validator.py +++ b/tools/schemacode/bidsschematools/validator.py @@ -168,7 +168,7 @@ def _add_subdirs(regex_string, variant, datatype, entity_definitions, formats, m for dir_entity in DIR_ENTITIES: if dir_entity in variant["entities"].keys(): format_selection = formats[entity_definitions[dir_entity]["format"]] - variable_field = format_selection['pattern'] + variable_field = format_selection["pattern"] shorthand = entity_definitions[dir_entity]["name"] if variant["entities"][dir_entity] == "required": regex_subdir = f"{shorthand}-(?P<{dir_entity}>{variable_field})/" @@ -297,7 +297,7 @@ def load_entities( variable_field = "|".join(entity_definitions[entity]["enum"]) else: format_selection = formats[entity_definitions[entity]["format"]] - variable_field = format_selection['pattern'] + variable_field = format_selection["pattern"] regex_entities = _add_entity( regex_entities, entity,