Skip to content

Commit

Permalink
fixed issue with absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
thequbit committed Sep 12, 2015
1 parent 76df5c8 commit 0dc390a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = yapot
version = 0.4.1
version = 0.4.2
author = Timothy Duffy
author-email = [email protected]
summary = Yet Another PDF OCR Tool
Expand Down
2 changes: 1 addition & 1 deletion yapot/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from yapot import convert_document
from .yapot import convert_document
11 changes: 8 additions & 3 deletions yapot/yapot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ def convert_document(pdf_filename,
temp_dir=str(uuid.uuid4()),password='',
thumb_prefix='thumb_page_',
pool_count=2):
filename = decrypt_pdf(pdf_filename, temp_dir, password)
just_pdf_filename = os.path.basename(pdf_filename)
temp_pdf_filename = '{0}/{1}'.format(temp_dir, just_pdf_filename)
shutil.copyfile(pdf_filename, temp_pdf_filename)
filename = decrypt_pdf(temp_pdf_filename, temp_dir, password)
filenames = split_pdf(filename, temp_dir)
for filename in filenames:
__pdf_filenames.put(filename)
pool = Pool()
pool.map_async(
_yapot_worker,
[(tid, pdf_filename, temp_dir, resolution) for
[(tid, just_pdf_filename, temp_dir, resolution) for
tid in range(0, pool_count)],
)
while __text_filenames.qsize() != len(filenames):
Expand Down Expand Up @@ -74,7 +77,9 @@ def decrypt_pdf(pdf_filename, temp_dir, password):
'''
Some PDFs are encrypted. This decrypts it.
'''
pdf_filename_unsecured = '{0}/{1}_unsecured.pdf'.format(temp_dir, pdf_filename)
pdf_filename_unsecured = '{0}_unsecured.pdf'.format(
pdf_filename
)
with open(os.devnull, 'w') as FNULL:
cli = [
'qpdf',
Expand Down

0 comments on commit 0dc390a

Please sign in to comment.