Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GU: Bills: fixes for chamber, versions #4727

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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