Skip to content

Commit

Permalink
GU: Bills: fixes for chamber, versions (#4727)
Browse files Browse the repository at this point in the history
  • Loading branch information
showerst authored Nov 20, 2023
1 parent 709b01d commit 309a086
Showing 1 changed file with 50 additions and 16 deletions.
66 changes: 50 additions & 16 deletions scrapers/gu/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,26 @@ def _process_bill(self, session: str, bill: str, root_url: str):
bill_obj.add_source(url=bill_link, note="Bill Introduced")
details = self._get_bill_details(bill_link)
if details.get("IntroducedDate", None):
bill_obj.add_action("Introduced", details["IntroducedDate"])
bill_obj.add_action(
"Introduced", details["IntroducedDate"], chamber="legislature"
)
if details.get("ReferredDate", None):
if details["Committee"]:
bill_obj.add_action(
"Referred To Committee",
details["ReferredDate"],
organization=details["Committee"],
chamber="legislature",
)
else:
bill_obj.add_action(
"Referred To Committee", details["ReferredDate"]
"Referred To Committee",
details["ReferredDate"],
chamber="legislature",
)

yield bill_obj
else:
bill_obj.add_document_link(
bill_obj.add_version_link(
url=bill_link, note="Bill Introduced", media_type="application/pdf"
)
status = xml.xpath("//li")[0].xpath("a/@href")[0]
Expand Down Expand Up @@ -156,24 +160,39 @@ def _process_bill(self, session: str, bill: str, root_url: str):
for link in xml.xpath("//li")[1:]:
url = link.xpath("a/@href")[0]
title = link.xpath("a")[0].text
bill_obj.add_document_link(
url=url, note=title, media_type="application/pdf"
)
if "fiscal note" in title.lower():
bill_obj.add_document_link(
url=url,
note=title,
media_type="application/pdf",
on_duplicate="ignore",
)
else:
bill_obj.add_version_link(
url=url,
note=title,
media_type="application/pdf",
on_duplicate="ignore",
)

# status PDF has introduced/passed/etc. dates
details = self._get_bill_details(status)
if details.get("IntroducedDate", None):
bill_obj.add_action("Introduced", details["IntroducedDate"])
bill_obj.add_action(
"Introduced", details["IntroducedDate"], chamber="legislature"
)
if details.get("ReferredDate", None):
if details["Committee"]:
bill_obj.add_action(
"Referred To Committee",
details["ReferredDate"],
organization=details["Committee"],
chamber="legislature",
)
else:
bill_obj.add_action(
"Referred To Committee", details["ReferredDate"]
"Referred To Committee",
details["ReferredDate"],
chamber="legislature",
)
yield bill_obj

Expand Down Expand Up @@ -215,7 +234,7 @@ def _process_resolution(self, session: str, bill: str, root_url: str):
result_date = self._tz.localize(dateutil.parser.parse(result_data[1]))

if result and result_date:
bill_obj.add_action(result, result_date)
bill_obj.add_action(result, result_date, chamber="legislature")

bill_obj.add_sponsorship(
name=sponsors[0],
Expand All @@ -233,15 +252,30 @@ def _process_resolution(self, session: str, bill: str, root_url: str):
for link in xml.xpath("//li"):
url = link.xpath("a/@href")[0]
title = link.xpath("a")[0].text
bill_obj.add_document_link(
url=url, note=title, media_type="application/pdf"
)
if "fiscal note" in title.lower():
bill_obj.add_document_link(
url=url,
note=title,
media_type="application/pdf",
on_duplicate="ignore",
)
else:
bill_obj.add_version_link(
url=url,
note=title,
media_type="application/pdf",
on_duplicate="ignore",
)

details = self._get_resolution_details(bill_link)
if details.get("IntroducedDate", None):
bill_obj.add_action("Introduced", details["IntroducedDate"])
bill_obj.add_action(
"Introduced", details["IntroducedDate"], chamber="legislature"
)
if details.get("PresentationDate", None):
bill_obj.add_action("Presented", details["PresentationDate"])
bill_obj.add_action(
"Presented", details["PresentationDate"], chamber="legislature"
)
yield bill_obj

def scrape(self, session):
Expand Down

0 comments on commit 309a086

Please sign in to comment.