@allansantos-dev/smart-tool 0.9.40 → 0.9.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  """Single source of the Smart Tool version and of the User-Agent sent to public APIs."""
2
2
  import re
3
3
 
4
- VERSION = "0.9.40"
4
+ VERSION = "0.9.42"
5
5
  _CONTACT_RE = re.compile(r"^(?:[^\s@()<>;]+@[^\s@()<>;]+\.[^\s@()<>;]+|https?://[^\s()<>;]+)$")
6
6
 
7
7
 
package/web_fetch.py CHANGED
@@ -38,8 +38,7 @@ SELECT_BUDGET_CHARS = 15_000
38
38
  CHUNK_CHARS = 2_000
39
39
  PAGE_FORMAT = 2
40
40
  MAX_DOWNLOAD_BYTES = 5 * 1024 * 1024
41
- PDF_MAX_PAGES = 300
42
- PDF_TIMEOUT_S = 30
41
+ PDF_INTERACTIVE_TIMEOUT_S = 30 # Override of document_text.PDF_TIMEOUT_S: a person waits for this answer, the indexer does not.
43
42
  MAX_REDIRECTS = 5
44
43
  HTTP_TIMEOUT_S = 20
45
44
  READ_CHUNK = 64 * 1024
@@ -212,12 +211,13 @@ def thin(text):
212
211
 
213
212
 
214
213
  def pdf_text(body, url, deadline):
215
- """Text of a PDF (pypdf, pure Python), page by page up to PDF_MAX_PAGES. The native WebFetch reads PDFs and the hook
216
- sends it here, so a PDF used to be a dead end (9 times in 10 days of transcripts). A hostile PDF can make pypdf
217
- parse for minutes, so it runs in a subprocess killed at the request's deadline (at most PDF_TIMEOUT_S)."""
218
- timeout = min(PDF_TIMEOUT_S, _left(deadline))
214
+ """Text of a PDF (pypdf, pure Python), page by page, with the page and character caps of document_text. The native
215
+ WebFetch reads PDFs and the hook sends it here, so a PDF used to be a dead end (9 times in 10 days of transcripts).
216
+ A hostile PDF can make pypdf parse for minutes, so it runs in a subprocess killed at the request's deadline (at most
217
+ PDF_INTERACTIVE_TIMEOUT_S, passed to document_text.run_pdf instead of the indexer's document_text.PDF_TIMEOUT_S)."""
218
+ timeout = min(PDF_INTERACTIVE_TIMEOUT_S, _left(deadline))
219
219
  try:
220
- return document_text.run_pdf(body, timeout, PDF_MAX_PAGES, PAGE_STORE_MAX_CHARS)
220
+ return document_text.run_pdf(body, timeout, document_text.PDF_MAX_PAGES, document_text.PDF_MAX_CHARS)
221
221
  except document_text.PdfTimeout:
222
222
  raise FetchError(f"PDF not read in {timeout:.0f}s ({url}).") from None
223
223
  except document_text.PdfUnreadable as exc: