Skip to content

Commit

Permalink
Get rid off accents if file names - they will be normalized
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrgredowski committed Aug 22, 2023
1 parent 328b33c commit 582e47a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bucket_of_utils/pdf/add_title_to_first_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<body>
<py-config type="toml">
packages = ["pdf-annotate"]
packages = ["pdf-annotate", "unidecode"]
[[fetch]]
files = ["./add_title_to_first_page.py"]
</py-config>
Expand All @@ -28,7 +28,7 @@ <h2>Config</h2>
</div>
<div class="col">
<h2>Files</h2>
<input class="form-control" type="file" id="file-upload" multiple="multiple">
<input class="form-control" type="file" id="file-upload" multiple="multiple" accept="application/pdf">
<div id="output_upload"></div>
<div class="row align-items-start">
<h2>Process</h2>
Expand Down
5 changes: 4 additions & 1 deletion bucket_of_utils/pdf/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from js import window
from pyodide.ffi import create_proxy
from pyodide.ffi import to_js
from unidecode import unidecode

CONFIG_DISABLED = True

Expand Down Expand Up @@ -90,7 +91,9 @@ async def _process_files(*_, **__):
reader = pdfrw.PdfReader(stream)
doc = pdf_annotate.PdfAnnotator(reader)

converted = add_file_name_annotation_to_pdf(doc=doc, file_name=file_.name)
file_name = unidecode(file_.name)

converted = add_file_name_annotation_to_pdf(doc=doc, file_name=file_name)
with tempfile.NamedTemporaryFile() as f:
converted.write(f)
f.seek(0)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies = [
"shellingham>=1.5.0.post1",
"pyodide-py>=0.23.4",
"types-requests>=2.31.0.2",
"unidecode>=1.3.6",
]
readme = "README.md"
requires-python = ">= 3.11"
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typer==0.9.0
types-requests==2.31.0.2
types-urllib3==1.26.25.14
typing-extensions==4.7.1
unidecode==1.3.6
urllib3==2.0.4
virtualenv==20.24.2
# The following packages are considered to be unsafe in a requirements file:
Expand Down
1 change: 1 addition & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ typer==0.9.0
types-requests==2.31.0.2
types-urllib3==1.26.25.14
typing-extensions==4.7.1
unidecode==1.3.6
urllib3==2.0.4

0 comments on commit 582e47a

Please sign in to comment.