Skip to content

Commit

Permalink
fix(va): Fix VA tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flooie committed Dec 12, 2023
1 parent 41008cc commit f3ca4b9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions juriscraper/opinions/united_states/state/va.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,33 @@ def __init__(self, *args, **kwargs):
self.court_id = self.__module__
self.url = "http://www.courts.state.va.us/scndex.htm"
self.status = "Published"
today = date.today()

def _process_html(self):
if self.test_mode_enabled():
today = datetime.strptime("11/20/2023", "%m/%d/%Y").date()
self.two_months_ago = today - timedelta(days=60)
else:
today = date.today()

def _process_html(self):
for row in self.html.xpath("//p"):
links = row.xpath(".//a")
if len(links) != 2:
continue
name = row.xpath(".//b/text()")[0].strip()
summary = row.text_content().split(name)[1].strip()
date = summary.split("\n")[0].strip()
if "Revised" in date:
date = date.split("Revised")[1].strip().strip(")")

date_object = datetime.strptime(date, "%m/%d/%Y").date()
if date_object < self.two_months_ago:
continue
date_str = summary.split("\n")[0].strip()
if "Revised" in date_str:
date_str = date_str.split("Revised")[1].strip().strip(")")
date_object = datetime.strptime(date_str, "%m/%d/%Y").date()
if date_object < today - timedelta(days=60):
# Stop after two months
break

self.cases.append(
{
"name": row.xpath(".//b/text()")[0].strip(),
"docket": links[0].get("name"),
"url": links[1].get("href"),
"summary": summary,
"date": date,
"date": date_str,
}
)

0 comments on commit f3ca4b9

Please sign in to comment.