Skip to content

Commit

Permalink
Merge pull request #5103 from openstates/va-fix-key-error-docs-vote-m…
Browse files Browse the repository at this point in the history
…otions

VA: fix key errors around handling source API data
  • Loading branch information
jessemortenson authored Nov 27, 2024
2 parents e19511b + 6d24b09 commit 5dc3ee1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scrapers/va/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def add_actions(self, bill: Bill, legislation_id: str):

# map reference numbers back to their actions for impact filenames
# HB9F122.PDF > { 'HB9F122' => "Impact statement from DPB (HB9)" }
if row["ReferenceNumber"]:
ref_num = row["ReferenceNumber"].split(".")[0]
if row["ReferenceNumber"] and row["ReferenceNumber"].strip() != "":
ref_num = row["ReferenceNumber"].split(".")[0].strip()
self.ref_num_map[ref_num] = row["Description"]

def add_carryover_related_bill(self, bill: Bill):
Expand Down Expand Up @@ -195,7 +195,13 @@ def add_versions(self, bill: Bill, legislation_id: str):
if row["ImpactFile"]:
for impact in row["ImpactFile"]:
# map 241HB9F122 => HB9F122
action = self.ref_num_map[impact["ReferenceNumber"][3:]]
# however somtimes ReferenceNumber does NOT have a weird prefix
if impact["ReferenceNumber"][3:] in self.ref_num_map:
action = self.ref_num_map[impact["ReferenceNumber"][3:]]
elif impact["ReferenceNumber"] in self.ref_num_map:
action = self.ref_num_map[impact["ReferenceNumber"]]
else:
action = "Unknown"
bill.add_document_link(
action, impact["FileURL"], media_type="application/pdf"
)
Expand Down Expand Up @@ -229,6 +235,8 @@ def add_votes(self, bill: Bill, legislation_id: str):
vote_date = dateutil.parser.parse(row["VoteDate"]).date()

motion_text = row["VoteActionDescription"]
if motion_text is None:
motion_text = row["LegislationActionDescription"]

# the api returns 'Continued to %NextSessionYear% in Finance' so fix that
motion_text = motion_text.replace(
Expand Down

0 comments on commit 5dc3ee1

Please sign in to comment.