Skip to content

feat(tames) add email parser for casemail notifications#1812

Merged
MorganBennetDev merged 6 commits intomainfrom
tames/parse-emails
Mar 9, 2026
Merged

feat(tames) add email parser for casemail notifications#1812
MorganBennetDev merged 6 commits intomainfrom
tames/parse-emails

Conversation

@Brennan-Chesley-FLP
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread tests/local/test_StateTexasTest.py Outdated
)
from juriscraper.state.texas.supreme_court import TexasSupremeCourtScraper
from tests import TESTS_ROOT_EXAMPLES_STATES
from tests import TESTS_ROOT_EXAMPLES_STATES, Path
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please import this from pathlib.

Comment thread juriscraper/state/texas/email.py Outdated
if not link:
return default
case_number = parse_qs(urlparse(link).query)["cn"][0]
return {"url": link, "case_number": case_number}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a parser like juriscraper/scotus/scotus_email.py?

Comment thread tests/local/test_StateTexasTest.py Outdated
self.parse_files(path_root, "*.html", TexasCourtOfAppealsScraper)


class TamesEmailParsingTest(unittest.TestCase):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we create a parser like we did for SCOTUS, we can use the existing test infrastructure instead of creating a custom special case.

@Brennan-Chesley-FLP
Copy link
Copy Markdown
Contributor Author

Refactored the SCOTUSEmail parser to inherit from a base class that does some of the common email parsing work. It exposes a _parse_text, parse (delegates to previous) and the subclasses implement their own data methods. Uses the Pacer test case infra for email parse testing now in the Tames case.

Totally open to revising this base class. Also open to planning on revising it after we've looked at a couple more notification emails.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just create a method to get the first text/html non-multipart content part from an email and turn it into an lxml tree? Then we could use that method in the SCOTUS and TAMES email parsers (and potentially future ones) to avoid duplicating code. Right now a whole base class feels like premature abstraction.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

@MorganBennetDev
Copy link
Copy Markdown
Contributor

@Brennan-Chesley-FLP There have been no new changes since the last review.

@Brennan-Chesley-FLP
Copy link
Copy Markdown
Contributor Author

@Brennan-Chesley-FLP There have been no new changes since the last review.

Nothing 4 or 5 git push -fs can't fix.

Copy link
Copy Markdown
Contributor

@MorganBennetDev MorganBennetDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes. Just some minor tweaks and this should be good to go. Also, don't forget to update CHANGES.md.

Comment thread juriscraper/state/texas/email.py Outdated
)
return

court_name = subject[len(SUBJECT_PREFIX) :]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use removeprefix for clarity.

Comment thread juriscraper/state/texas/email.py
Comment thread juriscraper/state/texas/email.py
Comment thread juriscraper/state/texas/email.py Outdated
url: str


class TamesEmail:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should extend AbstractParser until we come up with a better approach.

Comment thread juriscraper/state/texas/email.py
@Brennan-Chesley-FLP
Copy link
Copy Markdown
Contributor Author

I think the latest should cover the minor tweaks you suggested.

MorganBennetDev
MorganBennetDev previously approved these changes Mar 6, 2026
Copy link
Copy Markdown
Contributor

@MorganBennetDev MorganBennetDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@MorganBennetDev
Copy link
Copy Markdown
Contributor

@Brennan-Chesley-FLP Please update the changelog so this can auto-merge.

@MorganBennetDev MorganBennetDev merged commit a0e884b into main Mar 9, 2026
9 checks passed
@MorganBennetDev MorganBennetDev deleted the tames/parse-emails branch March 9, 2026 14:38
@github-project-automation github-project-automation Bot moved this from To Do to Done in Sprint (Web Team) Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants