Skip to content

Commit

Permalink
Merge pull request #1303 from freelawproject/fix-corrects-return-type…
Browse files Browse the repository at this point in the history
…-download-pdf
  • Loading branch information
mlissner authored Jan 20, 2025
2 parents 2839316 + e6ad00a commit 9974c8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Releases are also tagged in git, if that's helpful.

## Coming up

- N/A
- Fixes:
- `AppellateDocketReport.download_pdf` now returns a two-tuple containing the
response object or None and a str. This aligns with the changes introduced
in v 2.5.1.

## Current

Expand Down
14 changes: 9 additions & 5 deletions juriscraper/pacer/appellate_docket.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from lxml import html
from lxml.etree import _ElementUnicodeResult
from requests import Response

from ..lib.judge_parsers import normalize_judge_string
from ..lib.log_tools import make_default_logger
Expand Down Expand Up @@ -260,13 +261,16 @@ def parse(self):
self._clear_caches()
super().parse()

def download_pdf(self, pacer_doc_id, pacer_case_id=None):
def download_pdf(
self, pacer_doc_id, pacer_case_id=None
) -> tuple[Optional[Response], str]:
"""Download a PDF from an appellate court.
:param pacer_case_id: The case ID for the docket
:param pacer_doc_id: The document ID for the item.
:return: request.Response object containing the PDF, if one can be
found, else returns None.
:return: A tuple of the request.Response object containing a PDF, if
one can be found (is not sealed, gone, etc.). And a string indicating
the error message, if there is one or else an empty string.
This is a functional curl command to get a PDF (though the cookies have
been changed to protect the innocent):
Expand Down Expand Up @@ -331,8 +335,8 @@ def download_pdf(self, pacer_doc_id, pacer_case_id=None):
pacer_doc_id,
self.court_id,
)
return r
return None
return r, ""
return None, "Unable to download PDF."

@property
def metadata(self):
Expand Down

0 comments on commit 9974c8c

Please sign in to comment.