From a3292147e911c74a35d3ccfac9cccc8a09120b18 Mon Sep 17 00:00:00 2001 From: Matt Travers Date: Thu, 29 Sep 2022 15:43:58 -0400 Subject: [PATCH 01/10] Added SchB and OPERATING_EXPENDITURE schemas --- bin/generate-starter-schema.py | 140 ++- docs/BUS_LAB_NON_CONT_ACC.html | 2 +- docs/Contact_Candidate.html | 6 +- docs/Contact_Candidate_spec.html | 4 +- docs/Contact_Committee.html | 9 +- docs/Contact_Committee_spec.html | 4 +- docs/Contact_Individual.html | 14 +- docs/Contact_Individual_spec.html | 4 +- docs/Contact_Organization.html | 8 +- docs/Contact_Organization_spec.html | 4 +- docs/EAR_MEMO.html | 2 +- docs/EAR_REC.html | 2 +- docs/EAR_REC_CONVEN_ACC.html | 2 +- docs/EAR_REC_HQ_ACC.html | 2 +- docs/EAR_REC_RECNT_ACC.html | 2 +- docs/F3X.html | 2 +- docs/HDR.html | 2 +- docs/INDV_REC.html | 2 +- docs/IND_NP_CONVEN_ACC.html | 2 +- docs/IND_NP_HQ_ACC.html | 2 +- docs/IND_NP_RECNT_ACC.html | 2 +- docs/IND_RECNT_REC.html | 2 +- docs/IND_REC_NON_CONT_ACC.html | 2 +- docs/JF_TRAN.html | 2 +- docs/JF_TRAN_IND_MEMO.html | 2 +- docs/JF_TRAN_NP_CONVEN_ACC.html | 2 +- docs/JF_TRAN_NP_CONVEN_PAC_MEMO.html | 2 +- docs/JF_TRAN_NP_HQ_ACC.html | 2 +- docs/JF_TRAN_NP_HQ_PAC_MEMO.html | 2 +- docs/JF_TRAN_NP_RECNT_ACC.html | 2 +- docs/JF_TRAN_NP_RECNT_PAC_MEMO.html | 2 +- docs/JF_TRAN_PAC_MEMO.html | 2 +- docs/JF_TRAN_PAC_MEMO_spec.html | 2 +- docs/JF_TRAN_PARTY_MEMO.html | 2 +- docs/JF_TRAN_TRIB_MEMO.html | 2 +- docs/OFFSET_TO_OPEX.html | 2 +- docs/OPERATING_EXPENDITURE.html | 22 + docs/OPERATING_EXPENDITURE_spec.html | 270 +++++ docs/OTH_CMTE_NON_CONT_ACC.html | 2 +- docs/OTH_REC.html | 2 +- docs/PAC_EAR_MEMO.html | 2 +- docs/PAC_EAR_REC.html | 2 +- docs/PAC_NON_FED_REC.html | 2 +- docs/PAC_NON_FED_RET.html | 2 +- docs/PAC_NP_CONVEN_ACC.html | 2 +- docs/PAC_NP_HQ_ACC.html | 2 +- docs/PAC_NP_RECNT_ACC.html | 2 +- docs/PAC_REC.html | 2 +- docs/PAC_RECNT_REC.html | 2 +- docs/PAC_RET.html | 2 +- docs/PARTN_MEMO.html | 2 +- docs/PARTY_NP_RECNT_ACC.html | 2 +- docs/PARTY_REC.html | 2 +- docs/PARTY_RECNT_REC.html | 2 +- docs/PARTY_RET.html | 2 +- docs/REATT_FROM.html | 2 +- docs/REATT_TO.html | 2 +- docs/RET_REC.html | 2 +- docs/SchA.html | 2 +- docs/SchB.html | 36 + docs/SchB_spec.html | 502 +++++++++ docs/TRAN.html | 2 +- docs/TRIB_NP_CONVEN_ACC.html | 2 +- docs/TRIB_NP_HQ_ACC.html | 2 +- docs/TRIB_NP_RECNT_ACC.html | 2 +- docs/TRIB_REC.html | 2 +- docs/TRIB_RECNT_REC.html | 2 +- docs/Text.html | 2 +- docs/index.html | 53 +- schema/OPERATING_EXPENDITURE.json | 527 ++++++++++ schema/SchB.json | 923 ++++++++++++++++ .../disbursements/29-Conv.Ind.Refund.json | 504 +++++++++ .../29-Conv.Reg.FilerRefund.json | 461 ++++++++ .../disbursements/29-Conv.TribalRefund.json | 415 ++++++++ .../disbursements/29-ConvetionAccount.json | 527 ++++++++++ .../backlog/disbursements/29-HQAccount.json | 527 ++++++++++ .../disbursements/29-HQInd.Refund.json | 504 +++++++++ .../disbursements/29-HQReg.FilerRefund.json | 461 ++++++++ .../disbursements/29-HQTribalRefund.json | 415 ++++++++ .../disbursements/29-RecountAccount.json | 415 ++++++++ .../disbursements/29-RecountInd.Refund.json | 504 +++++++++ .../29-RecountReg.FilerRefund.json | 461 ++++++++ .../disbursements/29-RecountTribalRefund.json | 415 ++++++++ .../disbursements/30b-debtpayment.json | 751 +++++++++++++ schema/backlog/disbursements/30b.json | 751 +++++++++++++ schema/backlog/disbursements/30bFEACC.json | 639 +++++++++++ .../backlog/disbursements/30bFEACCmemo.json | 752 +++++++++++++ .../backlog/disbursements/30bFEApayroll.json | 639 +++++++++++ schema/backlog/disbursements/30bVOID.json | 751 +++++++++++++ .../backlog/disbursements/30bpayrollmemo.json | 729 +++++++++++++ .../disbursements/30bstaffreimburse.json | 751 +++++++++++++ .../disbursements/30bstaffreimbursememo.json | 752 +++++++++++++ .../disbursements/AllocatedFEA-Debt.json | 694 ++++++++++++ .../disbursements/AllocatedFEAdisb.json | 694 ++++++++++++ .../disbursements/AllocatedFEAdisbCC.json | 582 ++++++++++ .../disbursements/AllocatedFEAdisbCCmemo.json | 695 ++++++++++++ .../disbursements/AllocatedFEAdisbVOID.json | 694 ++++++++++++ .../disbursements/AllocatedFEAstaffmemo.json | 695 ++++++++++++ .../AllocatedFEAstaffreimburse.json | 694 ++++++++++++ .../backlog/disbursements/AllocatedH4CC.json | 622 +++++++++++ .../disbursements/AllocatedH4CCmemo.json | 735 +++++++++++++ .../disbursements/AllocatedH4Payroll.json | 735 +++++++++++++ .../disbursements/AllocatedH4PayrollMemo.json | 712 +++++++++++++ .../AllocatedH4Purpose-Debt.json | 734 +++++++++++++ .../disbursements/AllocatedH4Purpose.json | 734 +++++++++++++ .../disbursements/AllocatedH4VOID.json | 734 +++++++++++++ .../AllocatedH4reimbursememo.json | 735 +++++++++++++ .../AllocatedH4reimbursement.json | 734 +++++++++++++ schema/backlog/disbursements/CCLine29.json | 415 ++++++++ .../disbursements/CCLine29NoncontAcct.json | 415 ++++++++ .../backlog/disbursements/CCLine29memo.json | 528 ++++++++++ .../disbursements/CCLine29memoNoncontrib.json | 528 ++++++++++ .../backlog/disbursements/CEPayrollmemo.json | 943 +++++++++++++++++ .../disbursements/CEStaffReimburse.json | 942 +++++++++++++++++ .../disbursements/CEStaffReimburseMemo.json | 966 +++++++++++++++++ .../disbursements/ContrtoOtherCMTE.json | 12 + .../disbursements/CoordinateExpenditure.json | 965 +++++++++++++++++ .../CoordinateExpenditureCC.json | 853 +++++++++++++++ .../CoordinateExpenditureCCmemo.json | 966 +++++++++++++++++ .../CoordinateExpenditurePayroll.json | 853 +++++++++++++++ .../CoordinatedExpenditure-Debt.json | 965 +++++++++++++++++ schema/backlog/disbursements/CreditCard.json | 415 ++++++++ .../backlog/disbursements/CreditCardMemo.json | 549 ++++++++++ schema/backlog/disbursements/DCS.json | 631 +++++++++++ schema/backlog/disbursements/DCS23.json | 924 ++++++++++++++++ schema/backlog/disbursements/DCS23memo.json | 802 ++++++++++++++ schema/backlog/disbursements/DCSCE.json | 965 +++++++++++++++++ schema/backlog/disbursements/DCSCEmemo.json | 966 +++++++++++++++++ schema/backlog/disbursements/DCSIE.json | 994 +++++++++++++++++ schema/backlog/disbursements/DCSIEmemo.json | 995 ++++++++++++++++++ schema/backlog/disbursements/Debtfor21a.json | 450 ++++++++ schema/backlog/disbursements/Debtfor21b.json | 450 ++++++++ schema/backlog/disbursements/Debtfor30b.json | 450 ++++++++ .../disbursements/DebtforAllocatedFEA.json | 450 ++++++++ schema/backlog/disbursements/DebtforCE.json | 450 ++++++++ schema/backlog/disbursements/DebtforIE.json | 450 ++++++++ .../DebtforOtherDisbursements.json | 450 ++++++++ schema/backlog/disbursements/IE.json | 993 +++++++++++++++++ .../backlog/disbursements/IEBeforeDissem.json | 995 ++++++++++++++++++ schema/backlog/disbursements/IECCMemo.json | 994 +++++++++++++++++ .../backlog/disbursements/IECreditCard.json | 881 ++++++++++++++++ schema/backlog/disbursements/IEPayroll.json | 881 ++++++++++++++++ .../backlog/disbursements/IEPayrollMemo.json | 971 +++++++++++++++++ .../disbursements/IEStaffReimburse.json | 971 +++++++++++++++++ .../disbursements/IEStaffReimburseMemo.json | 995 ++++++++++++++++++ schema/backlog/disbursements/IEVOID.json | 993 +++++++++++++++++ schema/backlog/disbursements/Line25VOID.json | 965 +++++++++++++++++ schema/backlog/disbursements/Line26.json | 526 +++++++++ schema/backlog/disbursements/Line27.json | 526 +++++++++ schema/backlog/disbursements/Line28A.json | 503 +++++++++ schema/backlog/disbursements/Line28AVOID.json | 503 +++++++++ schema/backlog/disbursements/Line28B.json | 458 ++++++++ schema/backlog/disbursements/Line28BVOID.json | 458 ++++++++ schema/backlog/disbursements/Line28C.json | 641 +++++++++++ schema/backlog/disbursements/Line28CVOID.json | 662 ++++++++++++ .../disbursements/Line28CVOIDofnonfedPAC.json | 662 ++++++++++++ schema/backlog/disbursements/Line29Void.json | 527 ++++++++++ .../backlog/disbursements/MultistateIE.json | 994 +++++++++++++++++ .../NoncontrAcctDisbursment.json | 527 ++++++++++ .../disbursements/NonfederalPACrefund.json | 641 +++++++++++ .../OperatingExpenditure-Debt.json | 527 ++++++++++ .../disbursements/OperatingExpenditure.json | 527 ++++++++++ .../OtherDisbursements-Debt.json | 527 ++++++++++ .../disbursements/Otherdisbursements.json | 527 ++++++++++ .../backlog/disbursements/PayrollCompany.json | 415 ++++++++ .../disbursements/PayrollCompanyLine29.json | 415 ++++++++ .../PayrollCompanyLine29NCAcct.json | 415 ++++++++ .../disbursements/PayrollCompanyMemo.json | 526 +++++++++ .../PayrollCompanyMemoNCAcct.json | 526 +++++++++ .../PayrollCompanyMemoline29.json | 526 +++++++++ .../disbursements/RecountDisbursments.json | 415 ++++++++ .../backlog/disbursements/RedesingationC.json | 698 ++++++++++++ .../backlog/disbursements/Reimbursement.json | 527 ++++++++++ .../disbursements/ReimbursementMemo.json | 528 ++++++++++ .../disbursements/ReimbursementMemo29.json | 528 ++++++++++ .../ReimbursementMemo29NCacct.json | 528 ++++++++++ schema/backlog/disbursements/ScheduleC.json | 531 ++++++++++ .../disbursements/StaffReimbursement.json | 527 ++++++++++ .../StaffReimbursementNoncontrib.json | 527 ++++++++++ .../disbursements/TransfertoAffilates.json | 460 ++++++++ schema/backlog/disbursements/VOID.json | 527 ++++++++++ schema/backlog/disbursements/VOID23.json | 12 + .../disbursements/contrtocandidate.json | 392 +++++++ .../backlog/disbursements/disbursements.xlsx | Bin 0 -> 492720 bytes .../backlog/disbursements/redesignationA.json | 12 + .../backlog/disbursements/redesignationB.json | 698 ++++++++++++ 186 files changed, 74678 insertions(+), 155 deletions(-) create mode 100644 docs/OPERATING_EXPENDITURE.html create mode 100644 docs/OPERATING_EXPENDITURE_spec.html create mode 100644 docs/SchB.html create mode 100644 docs/SchB_spec.html create mode 100644 schema/OPERATING_EXPENDITURE.json create mode 100644 schema/SchB.json create mode 100644 schema/backlog/disbursements/29-Conv.Ind.Refund.json create mode 100644 schema/backlog/disbursements/29-Conv.Reg.FilerRefund.json create mode 100644 schema/backlog/disbursements/29-Conv.TribalRefund.json create mode 100644 schema/backlog/disbursements/29-ConvetionAccount.json create mode 100644 schema/backlog/disbursements/29-HQAccount.json create mode 100644 schema/backlog/disbursements/29-HQInd.Refund.json create mode 100644 schema/backlog/disbursements/29-HQReg.FilerRefund.json create mode 100644 schema/backlog/disbursements/29-HQTribalRefund.json create mode 100644 schema/backlog/disbursements/29-RecountAccount.json create mode 100644 schema/backlog/disbursements/29-RecountInd.Refund.json create mode 100644 schema/backlog/disbursements/29-RecountReg.FilerRefund.json create mode 100644 schema/backlog/disbursements/29-RecountTribalRefund.json create mode 100644 schema/backlog/disbursements/30b-debtpayment.json create mode 100644 schema/backlog/disbursements/30b.json create mode 100644 schema/backlog/disbursements/30bFEACC.json create mode 100644 schema/backlog/disbursements/30bFEACCmemo.json create mode 100644 schema/backlog/disbursements/30bFEApayroll.json create mode 100644 schema/backlog/disbursements/30bVOID.json create mode 100644 schema/backlog/disbursements/30bpayrollmemo.json create mode 100644 schema/backlog/disbursements/30bstaffreimburse.json create mode 100644 schema/backlog/disbursements/30bstaffreimbursememo.json create mode 100644 schema/backlog/disbursements/AllocatedFEA-Debt.json create mode 100644 schema/backlog/disbursements/AllocatedFEAdisb.json create mode 100644 schema/backlog/disbursements/AllocatedFEAdisbCC.json create mode 100644 schema/backlog/disbursements/AllocatedFEAdisbCCmemo.json create mode 100644 schema/backlog/disbursements/AllocatedFEAdisbVOID.json create mode 100644 schema/backlog/disbursements/AllocatedFEAstaffmemo.json create mode 100644 schema/backlog/disbursements/AllocatedFEAstaffreimburse.json create mode 100644 schema/backlog/disbursements/AllocatedH4CC.json create mode 100644 schema/backlog/disbursements/AllocatedH4CCmemo.json create mode 100644 schema/backlog/disbursements/AllocatedH4Payroll.json create mode 100644 schema/backlog/disbursements/AllocatedH4PayrollMemo.json create mode 100644 schema/backlog/disbursements/AllocatedH4Purpose-Debt.json create mode 100644 schema/backlog/disbursements/AllocatedH4Purpose.json create mode 100644 schema/backlog/disbursements/AllocatedH4VOID.json create mode 100644 schema/backlog/disbursements/AllocatedH4reimbursememo.json create mode 100644 schema/backlog/disbursements/AllocatedH4reimbursement.json create mode 100644 schema/backlog/disbursements/CCLine29.json create mode 100644 schema/backlog/disbursements/CCLine29NoncontAcct.json create mode 100644 schema/backlog/disbursements/CCLine29memo.json create mode 100644 schema/backlog/disbursements/CCLine29memoNoncontrib.json create mode 100644 schema/backlog/disbursements/CEPayrollmemo.json create mode 100644 schema/backlog/disbursements/CEStaffReimburse.json create mode 100644 schema/backlog/disbursements/CEStaffReimburseMemo.json create mode 100644 schema/backlog/disbursements/ContrtoOtherCMTE.json create mode 100644 schema/backlog/disbursements/CoordinateExpenditure.json create mode 100644 schema/backlog/disbursements/CoordinateExpenditureCC.json create mode 100644 schema/backlog/disbursements/CoordinateExpenditureCCmemo.json create mode 100644 schema/backlog/disbursements/CoordinateExpenditurePayroll.json create mode 100644 schema/backlog/disbursements/CoordinatedExpenditure-Debt.json create mode 100644 schema/backlog/disbursements/CreditCard.json create mode 100644 schema/backlog/disbursements/CreditCardMemo.json create mode 100644 schema/backlog/disbursements/DCS.json create mode 100644 schema/backlog/disbursements/DCS23.json create mode 100644 schema/backlog/disbursements/DCS23memo.json create mode 100644 schema/backlog/disbursements/DCSCE.json create mode 100644 schema/backlog/disbursements/DCSCEmemo.json create mode 100644 schema/backlog/disbursements/DCSIE.json create mode 100644 schema/backlog/disbursements/DCSIEmemo.json create mode 100644 schema/backlog/disbursements/Debtfor21a.json create mode 100644 schema/backlog/disbursements/Debtfor21b.json create mode 100644 schema/backlog/disbursements/Debtfor30b.json create mode 100644 schema/backlog/disbursements/DebtforAllocatedFEA.json create mode 100644 schema/backlog/disbursements/DebtforCE.json create mode 100644 schema/backlog/disbursements/DebtforIE.json create mode 100644 schema/backlog/disbursements/DebtforOtherDisbursements.json create mode 100644 schema/backlog/disbursements/IE.json create mode 100644 schema/backlog/disbursements/IEBeforeDissem.json create mode 100644 schema/backlog/disbursements/IECCMemo.json create mode 100644 schema/backlog/disbursements/IECreditCard.json create mode 100644 schema/backlog/disbursements/IEPayroll.json create mode 100644 schema/backlog/disbursements/IEPayrollMemo.json create mode 100644 schema/backlog/disbursements/IEStaffReimburse.json create mode 100644 schema/backlog/disbursements/IEStaffReimburseMemo.json create mode 100644 schema/backlog/disbursements/IEVOID.json create mode 100644 schema/backlog/disbursements/Line25VOID.json create mode 100644 schema/backlog/disbursements/Line26.json create mode 100644 schema/backlog/disbursements/Line27.json create mode 100644 schema/backlog/disbursements/Line28A.json create mode 100644 schema/backlog/disbursements/Line28AVOID.json create mode 100644 schema/backlog/disbursements/Line28B.json create mode 100644 schema/backlog/disbursements/Line28BVOID.json create mode 100644 schema/backlog/disbursements/Line28C.json create mode 100644 schema/backlog/disbursements/Line28CVOID.json create mode 100644 schema/backlog/disbursements/Line28CVOIDofnonfedPAC.json create mode 100644 schema/backlog/disbursements/Line29Void.json create mode 100644 schema/backlog/disbursements/MultistateIE.json create mode 100644 schema/backlog/disbursements/NoncontrAcctDisbursment.json create mode 100644 schema/backlog/disbursements/NonfederalPACrefund.json create mode 100644 schema/backlog/disbursements/OperatingExpenditure-Debt.json create mode 100644 schema/backlog/disbursements/OperatingExpenditure.json create mode 100644 schema/backlog/disbursements/OtherDisbursements-Debt.json create mode 100644 schema/backlog/disbursements/Otherdisbursements.json create mode 100644 schema/backlog/disbursements/PayrollCompany.json create mode 100644 schema/backlog/disbursements/PayrollCompanyLine29.json create mode 100644 schema/backlog/disbursements/PayrollCompanyLine29NCAcct.json create mode 100644 schema/backlog/disbursements/PayrollCompanyMemo.json create mode 100644 schema/backlog/disbursements/PayrollCompanyMemoNCAcct.json create mode 100644 schema/backlog/disbursements/PayrollCompanyMemoline29.json create mode 100644 schema/backlog/disbursements/RecountDisbursments.json create mode 100644 schema/backlog/disbursements/RedesingationC.json create mode 100644 schema/backlog/disbursements/Reimbursement.json create mode 100644 schema/backlog/disbursements/ReimbursementMemo.json create mode 100644 schema/backlog/disbursements/ReimbursementMemo29.json create mode 100644 schema/backlog/disbursements/ReimbursementMemo29NCacct.json create mode 100644 schema/backlog/disbursements/ScheduleC.json create mode 100644 schema/backlog/disbursements/StaffReimbursement.json create mode 100644 schema/backlog/disbursements/StaffReimbursementNoncontrib.json create mode 100644 schema/backlog/disbursements/TransfertoAffilates.json create mode 100644 schema/backlog/disbursements/VOID.json create mode 100644 schema/backlog/disbursements/VOID23.json create mode 100644 schema/backlog/disbursements/contrtocandidate.json create mode 100644 schema/backlog/disbursements/disbursements.xlsx create mode 100644 schema/backlog/disbursements/redesignationA.json create mode 100644 schema/backlog/disbursements/redesignationB.json diff --git a/bin/generate-starter-schema.py b/bin/generate-starter-schema.py index f688fd3c..2232540c 100644 --- a/bin/generate-starter-schema.py +++ b/bin/generate-starter-schema.py @@ -21,22 +21,34 @@ import os import re -parser = argparse.ArgumentParser(description='Convert the FEC validation Excel' - ' spreadsheet into JSON schema documents.') -parser.add_argument('excel_filename', help='an excel filename that will be' - ' parsed to generate JSON schema docs') -parser.add_argument('--sheets-to-generate', help='a json file containing an' - ' array of sheet names to be parsed from the excel file') -parser.add_argument('--version') +parser = argparse.ArgumentParser( + description="Convert the FEC validation Excel" + " spreadsheet into JSON schema documents." +) +parser.add_argument( + "excel_filename", + help="an excel filename that will be" " parsed to generate JSON schema docs", +) +parser.add_argument( + "--sheets-to-generate", + help="a json file containing an" + " array of sheet names to be parsed from the excel file", +) +parser.add_argument("--version") args = parser.parse_args() -EXCEL_FILENAME = args.excel_filename or \ - "Form_3X_Receipts_Vendor_10.20.2020.xlsx" -SCHEMA_ID_PREFIX = ("https://github.com/fecgov/fecfile-validate/blob/" - "main/schema") +EXCEL_FILENAME = args.excel_filename or "Form_3X_Receipts_Vendor_10.20.2020.xlsx" +SCHEMA_ID_PREFIX = "https://github.com/fecgov/fecfile-validate/blob/" "main/schema" VERSION = args.version or "v0.0.0.0" -SHEETS_TO_SKIP = ['All receipts', 'Version 8.3', 'SUMMARY OF CHANGES', - "All Schedule A Transactions", "ScheduleC", "Schedule C1", - "Scedule C2"] +SHEETS_TO_SKIP = [ + "All receipts", + "Version 8.3", + "SUMMARY OF CHANGES", + "All Schedule A Transactions", + "ScheduleC", + "Schedule C1", + "Scedule C2", + "All disbursements", +] # Column postions of fields in the spreadsheet row array @@ -53,12 +65,12 @@ class Columns(Enum): FIELD_FORM_ASSOCIATION = 8 def get(self, row, has_autopopulate): - index = self.value if has_autopopulate or \ - self.value <= 3 else self.value - 1 + index = self.value if has_autopopulate or self.value <= 3 else self.value - 1 value = row[index] if index < len(row) else None return value.strip() if isinstance(value, str) else value -def convert_row_to_property(row, sheet_has_autopopulate):# noqa + +def convert_row_to_property(row, sheet_has_autopopulate): # noqa """Take a row from the spreadsheet and convert it into a schema object. Args: @@ -75,33 +87,40 @@ def convert_row_to_property(row, sheet_has_autopopulate):# noqa if col != Columns.AUTO_POPULATE or sheet_has_autopopulate: spec[col.name] = col.get(row, sheet_has_autopopulate) - title = spec.get(Columns.FIELD_DESCRIPTION.name) + title = str(spec.get(Columns.FIELD_DESCRIPTION.name)) field_type = spec.get(Columns.TYPE.name) required = spec.get(Columns.REQUIRED.name) sample_data = spec.get(Columns.SAMPLE_DATA.name) rule_ref = spec.get(Columns.RULE_REFERENCE.name) - token = title.replace("\n", "_").replace(" ", "_").replace(".", "")\ - .replace("(", "").replace(")", "").replace("/", "_")\ - .replace("__", "_").lower() + token = ( + title.replace("\n", "_") + .replace(" ", "_") + .replace(".", "") + .replace("(", "") + .replace(")", "") + .replace("/", "_") + .replace("__", "_") + .lower() + ) # Prepend tokens that start with a number (presumed to be a line number) # with capital letter "L". if token[0].isdigit(): - token = 'L' + token + token = "L" + token prop["title"] = title prop["description"] = "" if field_type.startswith("AMT-"): prop["type"] = "number" prop["minimum"] = 0 - prop["maximum"] = int('9' * int(field_type.split('-')[1])) + prop["maximum"] = int("9" * int(field_type.split("-")[1])) if field_type.startswith("NUM-") or field_type.startswith("N-"): - length = field_type.split('-')[1].strip() + length = field_type.split("-")[1].strip() prop["type"] = "string" prop["minLength"] = 0 prop["maxLength"] = int(length) - prop["pattern"] = rf'^\d{{0,{length}}}$' + prop["pattern"] = rf"^\d{{0,{length}}}$" if field_type == "Dropdown": prop["type"] = "string" @@ -112,11 +131,11 @@ def convert_row_to_property(row, sheet_has_autopopulate):# noqa if field_type == "A-1" and rule_ref == "Check-box": prop["type"] = "boolean" else: - length = field_type.split('-')[1].strip() + length = field_type.split("-")[1].strip() prop["type"] = "string" prop["minLength"] = 0 prop["maxLength"] = int(length) - prop["pattern"] = f'^[ A-Za-z0-9]{{0,{length}}}$' + prop["pattern"] = f"^[ A-Za-z0-9]{{0,{length}}}$" if sample_data: prop["examples"] = [sample_data] @@ -131,51 +150,59 @@ def convert_row_to_property(row, sheet_has_autopopulate):# noqa wb = openpyxl.load_workbook(EXCEL_FILENAME) sheets_to_generate = None if args.sheets_to_generate is not None: - with open(os.path.join(os.getcwd(), args.sheets_to_generate), 'r') as f: + with open(os.path.join(os.getcwd(), args.sheets_to_generate), "r") as f: sheets_to_generate = json.load(f) print(sheets_to_generate) trans_type_hits = {} for ws in wb.worksheets: - if ((sheets_to_generate is not None and ws.title not in sheets_to_generate) - or ws.title in SHEETS_TO_SKIP): + if ( + sheets_to_generate is not None and ws.title not in sheets_to_generate + ) or ws.title in SHEETS_TO_SKIP: continue print(ws.title) - title = ws.title.replace(' ', '') + + title = ws.title.replace(" ", "") output_file = title + ".json" - print(f'Parsing {output_file}...') + print(f"Parsing {output_file}...") - sheet_has_autopopulate = ws.cell(3, 5).value is not None and \ - ws.cell(3, 5).value.strip() == 'Auto populate' + sheet_has_autopopulate = ( + ws.cell(3, 5).value is not None + and ws.cell(3, 5).value.strip() == "Auto populate" + ) schema_properties = {} required_rows = [] recommended_rows = [] for row in ws.iter_rows(min_row=5, max_col=8, values_only=True): - if (not Columns.COL_SEQ.get(row, sheet_has_autopopulate) - or Columns.COL_SEQ.get(row, sheet_has_autopopulate) == "--" - or not Columns.FIELD_DESCRIPTION.get(row, - sheet_has_autopopulate) - or not Columns.TYPE.get(row, sheet_has_autopopulate) - or len(row) > 10): + if ( + not Columns.COL_SEQ.get(row, sheet_has_autopopulate) + or Columns.COL_SEQ.get(row, sheet_has_autopopulate) == "--" + or not Columns.FIELD_DESCRIPTION.get(row, sheet_has_autopopulate) + or not Columns.TYPE.get(row, sheet_has_autopopulate) + or len(row) > 10 + ): continue - token, prop, is_required, is_recommended = \ - convert_row_to_property(row, sheet_has_autopopulate) + token, prop, is_required, is_recommended = convert_row_to_property( + row, sheet_has_autopopulate + ) if token == "transaction_type_identifier": - trans_type_id = \ - prop.get('fec_spec', {}).get(Columns.SAMPLE_DATA.name, - "") or "" - trans_type_hits[trans_type_id] = \ - (trans_type_hits.get(trans_type_id) or 0) + 1 - if (trans_type_hits[trans_type_id] > 1 or trans_type_id == ''): - output_file = trans_type_id + '-' + \ - str(trans_type_hits[trans_type_id]) + '.json' + trans_type_id = ( + prop.get("fec_spec", {}).get(Columns.SAMPLE_DATA.name, "") or "" + ) + trans_type_hits[trans_type_id] = ( + trans_type_hits.get(trans_type_id) or 0 + ) + 1 + if trans_type_hits[trans_type_id] > 1 or trans_type_id == "": + output_file = ( + trans_type_id + "-" + str(trans_type_hits[trans_type_id]) + ".json" + ) else: - output_file = trans_type_id + '.json' + output_file = trans_type_id + ".json" # Catch and mark token (i.e. spec property) clashes for manual fixing. if token in schema_properties: - token = token + '-DUPLICATE' + token = token + "-DUPLICATE" if is_required: required_rows.append(token) @@ -185,17 +212,18 @@ def convert_row_to_property(row, sheet_has_autopopulate):# noqa schema = { "$schema": "https://json-schema.org/draft-07/schema#", - "$id": f'{SCHEMA_ID_PREFIX}/{output_file}', + "$id": f"{SCHEMA_ID_PREFIX}/{output_file}", "version": VERSION, - "title": f'FEC {ws.title}', + "title": f"FEC {ws.title}", "description": ws.cell(1, 1).value, "type": "object", "required": required_rows, "fec_recommended": recommended_rows, "properties": schema_properties, - "additionalProperties": False + "additionalProperties": False, } f = open(output_file, "w") f.write(json.dumps(schema, indent=4)) f.close() - print('Done') + print("Done") + diff --git a/docs/BUS_LAB_NON_CONT_ACC.html b/docs/BUS_LAB_NON_CONT_ACC.html index de6f9eaf..dec4d9bf 100644 --- a/docs/BUS_LAB_NON_CONT_ACC.html +++ b/docs/BUS_LAB_NON_CONT_ACC.html @@ -13,4 +13,4 @@

Type: string or null
Must match regular expression: ^[0-9]{4}-[0-9]{2}-[0-9]{2}$
Example:

"2018-11-13"
 

Type: number

Value must be greater or equal to 0 and lesser or equal to 999999999.99


Example:

250
 

Type: number

Value must be greater or equal to 0 and lesser or equal to 999999999.99


Example:

1000
-

Type: string
Must match regular expression: ^[ -~]{0,100}$

Must be at least 0 characters long

Must be at most 100 characters long

Type: boolean or null

Type: string or null
Must match regular expression: ^[ -~]{0,100}$
\ No newline at end of file +

Type: string
Must match regular expression: ^[ -~]{0,100}$

Must be at least 0 characters long

Must be at most 100 characters long

Type: boolean or null

Type: string or null
Must match regular expression: ^[ -~]{0,100}$
\ No newline at end of file diff --git a/docs/Contact_Candidate.html b/docs/Contact_Candidate.html index bb13fa16..75e1af4b 100644 --- a/docs/Contact_Candidate.html +++ b/docs/Contact_Candidate.html @@ -1,4 +1,4 @@ - FEC Candidate

FEC Candidate


Candidate Contact

Type: object

If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

Type: object

Type: const
Specific value: "S"
Type: object

Type: string
Type: object

If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

Type: object

Type: const
Specific value: "H"
Type: object

Type: string

Type: string

Type: const
Specific value: "CAN"
Example:

"CAN"
+ FEC Candidate 

FEC Candidate


Candidate Contact

Type: object

If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

Type: object

Type: const
Specific value: "USA"
Type: object

Type: string
Type: object

If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

Type: object

Type: const
Specific value: "S"
Type: object

Type: string
Type: object

If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

Type: object

Type: const
Specific value: "H"
Type: object

Type: string

Type: string

Type: const
Specific value: "CAN"
Example:

"CAN"
 

Type: string
Must match regular expression: ^P[0-9]{8}$|^[H|S][0-9]{1}[A-Z]{2}[0-9]{5}$

Must be at least 0 characters long

Must be at most 9 characters long


Examples:

"P01234567"
 
"H0MD12345"
 
"S0MD12345"
@@ -10,9 +10,9 @@
 

Type: string
Must match regular expression: ^[ -~]{0,34}$

Must be at least 0 characters long

Must be at most 34 characters long


Example:

"123 Main Street"
 

Type: string or null
Must match regular expression: ^[ -~]{0,34}$

Type: string
Must match regular expression: ^[ -~]{0,30}$

Must be at least 0 characters long

Must be at most 30 characters long


Example:

"Anytown"
 

Type: string
Must match regular expression: ^[A-Z]{2}$

Must be at least 2 characters long

Must be at most 2 characters long


Example:

"WA"
-

Type: string
Must match regular expression: ^[ -~]{0,9}$

Must be at least 0 characters long

Must be at most 9 characters long


Example:

981110123
+

Type: string or null
Must match regular expression: ^[ -~]{0,9}$
Example:

981110123
 

Type: string or null
Must match regular expression: ^[ -~]{0,38}$
Example:

"XYZ Company"
 

Type: string or null
Must match regular expression: ^[ -~]{0,38}$
Example:

"QC Inspector"
 

Type: enum (of string)

Must be one of:

  • "H"
  • "S"
  • "P"

Example:

"H\nS\nP"
 

Type: string or null
Must match regular expression: ^[A-Z]{2}$
Example:

"WA"
-

Type: string or null
Must match regular expression: ^[0-9]{2}$

Type: string or null
Must match regular expression: ^\d{10}$

Type: string
\ No newline at end of file +

Type: string or null
Must match regular expression: ^[0-9]{2}$

Type: string or null
Must match regular expression: ^\+\d{1,3} \d{10}$

Type: string
\ No newline at end of file diff --git a/docs/Contact_Candidate_spec.html b/docs/Contact_Candidate_spec.html index d3ca01f4..a04bdceb 100644 --- a/docs/Contact_Candidate_spec.html +++ b/docs/Contact_Candidate_spec.html @@ -139,7 +139,7 @@ -