Skip to content

Commit

Permalink
VA: add related bills from prior session to represent carryover
Browse files Browse the repository at this point in the history
  • Loading branch information
jessemortenson committed Oct 31, 2024
1 parent 5d681d8 commit 3c681c9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scrapers/va/bills.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

import dateutil
import json
import lxml
Expand All @@ -11,6 +13,8 @@

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

four_digit_regex = re.compile("[0-9]{4}")


class VaBillScraper(Scraper):
tz = pytz.timezone("America/New_York")
Expand Down Expand Up @@ -80,6 +84,7 @@ def scrape(self, session=None):

self.add_actions(bill, row["LegislationID"])
self.add_versions(bill, row["LegislationID"])
self.add_carryover_related_bill(bill)
self.add_sponsors(bill, row["Patrons"])
yield from self.add_votes(bill, row["LegislationID"])
bill.add_abstract(subtitle, note="title")
Expand Down Expand Up @@ -124,6 +129,25 @@ def add_actions(self, bill: Bill, legislation_id: str):
ref_num = row["ReferenceNumber"].split(".")[0]
self.ref_num_map[ref_num] = row["Description"]

def add_carryover_related_bill(self, bill: Bill):
# Many bills are carried from one session to the next
# but this does not apply to special sessions
if four_digit_regex.fullmatch(bill.legislative_session) is not None:
prior_session = int(bill.legislative_session) - 1
else:
return

has_carryover_action = False
for action in bill.actions:
if (
f"continued to {bill.legislative_session}"
in action["description"].lower()
):
has_carryover_action = True

if has_carryover_action:
bill.add_related_bill(bill.identifier, f"{prior_session}", "prior-session")

def add_sponsors(self, bill: Bill, sponsors: list):
for row in sponsors:
primary = True if row["Name"] == "Chief Patron" else False
Expand Down

0 comments on commit 3c681c9

Please sign in to comment.