Skip to content

Commit

Permalink
Merge pull request #1822 from laws-africa/scripts
Browse files Browse the repository at this point in the history
this includes pdfjs-to-text in .env/bin so that it's available as an …
  • Loading branch information
longhotsummer authored May 24, 2024
2 parents c6d000e + 6deb290 commit 7409b7c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions peachjam/helpers.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import string
import subprocess
import tempfile
from datetime import date, datetime
from functools import wraps

import martor.utils
from django.conf import settings
from django.utils.translation import get_language_from_request
from languages_plus.models import Language

Expand Down Expand Up @@ -46,7 +46,7 @@ def pdfjs_to_text(fname):
"""Extract text from fname using pdfjs-compatible script."""
with tempfile.NamedTemporaryFile(suffix=".txt") as outf:
cmd = [
os.path.join(os.path.dirname(__file__), "..", "bin", "pdfjs-to-text"),
settings.PEACHJAM["PDFJS_TO_TEXT"],
fname,
outf.name,
]
Expand Down
1 change: 1 addition & 0 deletions peachjam/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"SEARCH_JURISDICTION_FILTER": False,
"MULTIPLE_JURISDICTIONS": False,
"MULTIPLE_LOCALITIES": False,
"PDFJS_TO_TEXT": "bin/pdfjs-to-text",
}

PEACHJAM["ES_INDEX"] = os.environ.get("ES_INDEX", slugify(PEACHJAM["APP_NAME"]))
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ dependencies = [
"sentry-sdk>=1.16.0",
"whitenoise>=6.0.0",
]

[tool.setuptools.data-files]
"bin" = ["bin/pdfjs-to-text"]

0 comments on commit 7409b7c

Please sign in to comment.