From 57abc9b1b852d320a42891ec66566ce50b79a081 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 11 Jan 2025 19:20:52 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../opinions/united_states/state/lactapp_2.py | 71 +++++++++++-------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/juriscraper/opinions/united_states/state/lactapp_2.py b/juriscraper/opinions/united_states/state/lactapp_2.py index a5b99ecc7..295bc69dc 100644 --- a/juriscraper/opinions/united_states/state/lactapp_2.py +++ b/juriscraper/opinions/united_states/state/lactapp_2.py @@ -1,8 +1,13 @@ -from datetime import datetime, date -from juriscraper.OpinionSiteLinear import OpinionSiteLinear -from juriscraper.lib.html_utils import get_row_column_text, get_row_column_links -from juriscraper.lib.date_utils import unique_year_month +from datetime import date, datetime + from juriscraper.AbstractSite import logger +from juriscraper.lib.date_utils import unique_year_month +from juriscraper.lib.html_utils import ( + get_row_column_links, + get_row_column_text, +) +from juriscraper.OpinionSiteLinear import OpinionSiteLinear + class Site(OpinionSiteLinear): first_opinion_date = datetime(2019, 7, 17) @@ -22,8 +27,8 @@ def __init__(self, *args, **kwargs): def _download(self): html = super()._download() if html is not None: - tables = html.cssselect('table#datatable') - if not tables or not tables[0].cssselect('tbody tr'): + tables = html.cssselect("table#datatable") + if not tables or not tables[0].cssselect("tbody tr"): self.year -= 1 self.url = f"{self.base_url}?opinion_year={self.year}" return self._download() @@ -32,39 +37,45 @@ def _download(self): def _process_html(self): if self.html is None: return - - tables = self.html.cssselect('table#datatable') - if tables and tables[0].cssselect('tbody tr'): + + tables = self.html.cssselect("table#datatable") + if tables and tables[0].cssselect("tbody tr"): logger.info(f"Processing cases for year: {self.year}") - for row in tables[0].cssselect('tbody tr'): + for row in tables[0].cssselect("tbody tr"): case_date = datetime.strptime( - get_row_column_text(row, 1), - '%m/%d/%Y' + get_row_column_text(row, 1), "%m/%d/%Y" ).date() - + # Skip if before first opinion date if case_date < self.first_opinion_date.date(): continue - + # Only apply date filtering during backscrape - if hasattr(self, 'back_scrape_iterable') and self.back_scrape_iterable: + if ( + hasattr(self, "back_scrape_iterable") + and self.back_scrape_iterable + ): if self.target_date: target_month = self.target_date.month target_year = self.target_date.year - if (case_date.year != target_year or - case_date.month != target_month): + if ( + case_date.year != target_year + or case_date.month != target_month + ): continue - - self.cases.append({ - "date": get_row_column_text(row, 1), - "docket": get_row_column_text(row, 2), - "name": get_row_column_text(row, 3), - "author": get_row_column_text(row, 4), - "disposition": get_row_column_text(row, 5), - "lower_court": get_row_column_text(row, 6), - "summary": get_row_column_text(row, 7), - "url": get_row_column_links(row, 8), - }) + + self.cases.append( + { + "date": get_row_column_text(row, 1), + "docket": get_row_column_text(row, 2), + "name": get_row_column_text(row, 3), + "author": get_row_column_text(row, 4), + "disposition": get_row_column_text(row, 5), + "lower_court": get_row_column_text(row, 6), + "summary": get_row_column_text(row, 7), + "url": get_row_column_links(row, 8), + } + ) def _download_backwards(self, target_date: date) -> None: logger.info(f"Backscraping for date: {target_date}") @@ -76,4 +87,6 @@ def _download_backwards(self, target_date: date) -> None: def make_backscrape_iterable(self, kwargs): super().make_backscrape_iterable(kwargs) - self.back_scrape_iterable = unique_year_month(self.back_scrape_iterable) \ No newline at end of file + self.back_scrape_iterable = unique_year_month( + self.back_scrape_iterable + )