Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes needed to be able to compile pdfminer.six with Cython #142

Merged
merged 5 commits into from
Jul 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pdfminer/ccitt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import six #Python 2+3 compatibility

import unittest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for? Was it included by mistake?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved in the main() and/or the main removed entirely and moved to some testing script outside of the main library code


if six.PY3:
def get_bytes(data):
for byte in data:
Expand Down Expand Up @@ -598,7 +600,7 @@ def close(self):
pygame.image.save(self.img, 'out.bmp')
return
for path in argv[1:]:
fp = file(path, 'rb')
fp = open(path, 'rb')
(_, _, k, w, h, _) = path.split('.')
parser = Parser(int(w))
parser.feedbytes(fp.read())
Expand Down
2 changes: 1 addition & 1 deletion pdfminer/cmapdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def do_keyword(self, pos, token):
def main(argv):
args = argv[1:]
for fname in args:
fp = file(fname, 'rb')
fp = open(fname, 'rb')
cmap = FileUnicodeMap()
#cmap = FileCMap()
CMapParser(cmap, fp).run()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pdfminer as package

requires = ['six', 'pycryptodome']
requires = ['six', 'pycryptodome', 'pygame']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, what is pygame needed for?

Copy link
Contributor Author

@mawoqiw mawoqiw Apr 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A function from unitest is called here without an import.
pygame is not listed among requirements but is called here and here

So far I haven't found much space for improvement in psparser.py, other than this, either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mawoqiw I think we should not add pygame as a dep... instead it should be removed. When was this introduced?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This main() should be removed entirely and moved to some testing script outside of the main library code and we cannot add pygame as a runtime dep

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right @pombredanne. pygame is indeed not required to use Cython, thanks.
With regards to main() function I would rather deal with it in a different merge request. Do you have any idea what is the purpose of that code?

if sys.version_info >= (3, 0):
requires.append('chardet')

Expand Down
4 changes: 2 additions & 2 deletions tools/pdf2html.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def convert(infp, outfp, path, codec='utf-8',
maxpages=0, maxfilesize=0, pagenos=None,
html=True):
# save the input file.
src = file(path, 'wb')
src = open(path, 'wb')
nbytes = 0
while 1:
data = infp.read(4096)
Expand All @@ -68,7 +68,7 @@ def convert(infp, outfp, path, codec='utf-8',
layoutmode='exact')
else:
device = TextConverter(rsrcmgr, outfp, codec=codec, laparams=laparams)
fp = file(path, 'rb')
fp = open(path, 'rb')
interpreter = PDFPageInterpreter(rsrcmgr, device)
for page in PDFPage.get_pages(fp, pagenos, maxpages=maxpages):
interpreter.process_page(page)
Expand Down