From a65c1379101c8b652dca9d266dd537955a661ce1 Mon Sep 17 00:00:00 2001 From: Eric Lipe Date: Fri, 15 Sep 2023 08:10:48 -0600 Subject: [PATCH] - Updated based on review feedback --- .../tdpservice/parsers/schema_defs/tanf/t7.py | 30 +++++++++---------- tdrs-backend/tdpservice/parsers/validators.py | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t7.py b/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t7.py index 570dfcab7..ab1129a83 100644 --- a/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t7.py +++ b/tdrs-backend/tdpservice/parsers/schema_defs/tanf/t7.py @@ -9,10 +9,10 @@ schemas = [] -validator_start_index = 7 -section_ind_start_index = 7 -stratum_start_index = 8 -families_start_index = 10 +validator_index = 7 +section_ind_index = 7 +stratum_index = 8 +families_index = 10 for i in range(1, 31): schemas.append( RowSchema( @@ -20,7 +20,7 @@ quiet_preparser_errors=i > 1, preparsing_validators=[ validators.notEmpty(0, 7), - validators.notEmpty(validator_start_index, validator_start_index + 24), + validators.notEmpty(validator_index, validator_index + 24), ], postparsing_validators=[], fields=[ @@ -32,20 +32,20 @@ TransformField(calendar_quarter_to_rpt_month_year(i % 3), item="3A", name='RPT_MONTH_YEAR', type='number', startIndex=2, endIndex=7, required=True, validators=[validators.dateYearIsLargerThan(1998), validators.dateMonthIsValid()]), - Field(item="4", name='TDRS_SECTION_IND', type='string', startIndex=section_ind_start_index, - endIndex=section_ind_start_index + 1, required=True, validators=[validators.oneOf(['1', '2'])]), - Field(item="5", name='STRATUM', type='string', startIndex=stratum_start_index, - endIndex=stratum_start_index + 2, required=True, validators=[validators.isInStringRange(1, 99)]), - Field(item="6A", name='FAMILIES_MONTH', type='number', startIndex=families_start_index, - endIndex=families_start_index + 7, required=True, validators=[validators.isInLimits(0, 9999999)]), + Field(item="4", name='TDRS_SECTION_IND', type='string', startIndex=section_ind_index, + endIndex=section_ind_index + 1, required=True, validators=[validators.oneOf(['1', '2'])]), + Field(item="5", name='STRATUM', type='string', startIndex=stratum_index, + endIndex=stratum_index + 2, required=True, validators=[validators.isInStringRange(1, 99)]), + Field(item="6A", name='FAMILIES_MONTH', type='number', startIndex=families_index, + endIndex=families_index + 7, required=True, validators=[validators.isInLimits(0, 9999999)]), ] ) ) index_offset = 0 if i % 3 != 0 else 24 - validator_start_index += index_offset - section_ind_start_index += index_offset - stratum_start_index += index_offset - families_start_index += 7 if i % 3 != 0 else 10 + validator_index += index_offset + section_ind_index += index_offset + stratum_index += index_offset + families_index += 7 if i % 3 != 0 else 10 t7 = SchemaManager(schemas=schemas) diff --git a/tdrs-backend/tdpservice/parsers/validators.py b/tdrs-backend/tdpservice/parsers/validators.py index 4fa89c1b6..c811a6ef1 100644 --- a/tdrs-backend/tdpservice/parsers/validators.py +++ b/tdrs-backend/tdpservice/parsers/validators.py @@ -166,7 +166,7 @@ def isBlank(): lambda value: f'{value} is not blank.' ) -def isInStringRange(lower, upper, zfill=1): +def isInStringRange(lower, upper): """Validate that string value is in a specific range.""" return make_validator( lambda value: int(value) >= lower and int(value) <= upper,