Skip to content

Commit

Permalink
- Pre-calculating item numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
elipe17 committed Oct 23, 2023
1 parent 529a801 commit 967fb1a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tdrs-backend/tdpservice/parsers/schema_defs/ssp/m7.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
section_ind_index = 7
stratum_index = 8
families_index = 10
for i in range(1, 31):
month_index = (i - 1) % 3
sub_item_labels = ['A', 'B', 'C']
families_item_number = f"5{sub_item_labels[month_index]}"

sub_item_labels = ['5A', '5B', '5C']
families_item_numbers = [sub_item_labels[i % 3] for i in range(30)]

for i in range(1, 31):
schemas.append(
RowSchema(
model=SSP_M7,
Expand All @@ -34,7 +34,7 @@
required=True, validators=[validators.dateYearIsLargerThan(1998),
validators.quarterIsValid()]),
TransformField(
transform_func=calendar_quarter_to_rpt_month_year(month_index),
transform_func=calendar_quarter_to_rpt_month_year((i - 1) % 3),
item="2A",
name='RPT_MONTH_YEAR',
type='number',
Expand All @@ -50,7 +50,7 @@
endIndex=section_ind_index + 1, required=True, validators=[validators.oneOf(['1', '2'])]),
Field(item="4", name='STRATUM', type='string', startIndex=stratum_index,
endIndex=stratum_index + 2, required=True, validators=[validators.isInStringRange(0, 99)]),
Field(item=families_item_number, name='FAMILIES_MONTH', type='number', startIndex=families_index,
Field(item=families_item_numbers[i - 1], name='FAMILIES_MONTH', type='number', startIndex=families_index,
endIndex=families_index + 7, required=True, validators=[validators.isInLimits(0, 9999999)]),
]
)
Expand Down

0 comments on commit 967fb1a

Please sign in to comment.