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

Enforce pep8 coding style #345

Merged
merged 34 commits into from
Dec 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
507eac0
Code Refractor: Use code-style enforcement #312
fakabbir Oct 25, 2019
88bbd3e
Add flake8 to travis-ci
pietermarsman Nov 5, 2019
459e429
Remove python 2 3 comment on six library. 891 errors > 870 errors.
pietermarsman Nov 11, 2019
8c22cdf
Remove class and functions comments that consist of just the name. 87…
pietermarsman Nov 11, 2019
51d0927
Fix flake8 errors in pdftypes.py. 855 errors > 833 errors.
pietermarsman Nov 11, 2019
8995074
Moving flake8 testing from .travis.yml to tox.ini to ensure local tes…
pietermarsman Nov 11, 2019
2f216f5
Cleanup pdfinterp.py and add documentation from PDF Reference
pietermarsman Nov 11, 2019
fc6acfc
Cleanup pdfpage.py
pietermarsman Nov 11, 2019
cc89a37
Cleanup pdffont.py
pietermarsman Nov 11, 2019
cf93de4
Clean psparser.py
pietermarsman Nov 11, 2019
cb05ae7
Cleanup high_level.py
pietermarsman Nov 11, 2019
bf3de47
Cleanup layout.py
pietermarsman Nov 11, 2019
ed65566
Cleanup pdfparser.py
pietermarsman Nov 11, 2019
9aea68b
Cleanup pdfcolor.py
pietermarsman Nov 11, 2019
3f19e17
Cleanup rijndael.py
pietermarsman Nov 11, 2019
b58844f
Cleanup converter.py
pietermarsman Nov 11, 2019
2e3ae75
Rename klass to cls if it is the class variable, to be more consisten…
pietermarsman Nov 11, 2019
c704b2a
Cleanup cmap.py
pietermarsman Nov 11, 2019
7d9604c
Cleanup pdfdevice.py
pietermarsman Nov 11, 2019
8bf5e79
flake8 ignore fontmetrics.py
pietermarsman Nov 11, 2019
6776ebc
Cleanup test_pdfminer_psparser.py
pietermarsman Nov 11, 2019
a96c44b
Fix flake8 in pdfdocument.py; 339 errors to go
pietermarsman Nov 17, 2019
deb5494
Fix flake8 utils.py; 326 errors togo
pietermarsman Nov 18, 2019
a416814
pep8 correction for few files in /tools/ 328 > 160 to go (#342)
fakabbir Dec 9, 2019
09aabe9
Fix ascii85.py errors
pietermarsman Dec 9, 2019
8174b1b
Fix error in getting index from target that does not exists
pietermarsman Dec 9, 2019
e7bc9da
Remove commented print lines
pietermarsman Dec 9, 2019
c94f5fe
Fix flake8 error in pdfinterp.py
pietermarsman Dec 9, 2019
c9101ad
Fix python2 specific error by removing argument from print statement
pietermarsman Dec 9, 2019
ed6c439
Ignore invalid python2 syntax
pietermarsman Dec 29, 2019
4a09fce
Update contributing.md
pietermarsman Dec 29, 2019
429848c
Added changelog
pietermarsman Dec 29, 2019
fb7498e
Merge branch 'develop' into pep8
pietermarsman Dec 29, 2019
7f76576
Remove unused import
pietermarsman Dec 29, 2019
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ python:
- "3.7"
- "3.8"
install:
- pip install tox-travis
- pip install tox-travis flake8
script:
- tox -r
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Changed
- Enforce pep8 coding style by adding flake8 to CI ([#345](https://github.com/pdfminer/pdfminer.six/pull/345))

## [20191110] - 2019-11-10

### Fixed
Expand Down
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Any contribution is appreciated! You might want to:
- If you report a bug in the results for a particular pdf, include that pdf. This allows others to replicate the
issue.
* Fix issues by [creating pull requests](https://help.github.com/en/articles/creating-a-pull-request).
* Help others by giving your thoughts on open issues and pull requests.
* Help others by sharing your thoughs in comments on issues and pull requests.

## Guidelines for creating issues

Expand All @@ -29,11 +29,15 @@ Any contribution is appreciated! You might want to:
* Pull requests should be merged to develop, not master. This ensures that master always equals the released version.
* Include unit tests when possible. In case of bugs, this will help to prevent the same mistake in the future. In case
of features, this will show that your code works correctly.
* Code should work for Python 2.7 and Python 3.x (for now), conform to PEP8 code style (with a line-width of 120)
and properly documented with docstrings.
* Code should work for Python 2.7 and Python 3.x (for now), conform to PEP8 code style (enforced by
[flake8](http://flake8.pycqa.org/en/latest/)) and properly documented with docstrings.
* Check spelling and grammar.
* Don't forget to update the [CHANGELOG.md](CHANGELOG.md#[Unreleased])

## Guidelines for posting comments

* [Be cordial and positive](https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way)

## Getting started

1. Clone the repository
Expand Down
5 changes: 3 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import os
import sys
sys.path.insert(0, os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../'))
sys.path.insert(0, os.path.join(
os.path.abspath(os.path.dirname(__file__)), '../../'))


# -- Project information -----------------------------------------------------
Expand Down Expand Up @@ -58,4 +59,4 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ['_static']
7 changes: 5 additions & 2 deletions pdfminer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@


if sys.version_info < (3, 0):
warnings.warn('On January 1st, 2020, pdfminer.six will stop supporting Python 2. Please upgrade to Python 3. For '
'more information see https://github.com/pdfminer/pdfminer.six/issues/194')
warnings.warn('On January 1st, 2020, '
'pdfminer.six will stop supporting Python 2. '
'Please upgrade to Python 3. '
'For more information see '
'https://github.com/pdfminer/pdfminer.six/issues/194')

if __name__ == '__main__':
print(__version__)
14 changes: 8 additions & 6 deletions pdfminer/arcfour.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@

"""

import six # Python 2+3 compatibility
## Arcfour
##
import six # Python 2+3 compatibility


class Arcfour(object):

def __init__(self, key):
s = [i for i in range(256)] #because Py3 range is not indexable
# because Py3 range is not indexable
s = [i for i in range(256)]
j = 0
klen = len(key)
for i in range(256):
j = (j + s[i] + six.indexbytes(key,i % klen)) % 256
j = (j + s[i] + six.indexbytes(key, i % klen)) % 256
(s[i], s[j]) = (s[j], s[i])
self.s = s
(self.i, self.j) = (0, 0)
Expand All @@ -34,7 +35,8 @@ def process(self, data):
r += six.int2byte(c ^ k)
(self.i, self.j) = (i, j)
return r

encrypt = decrypt = process


new = Arcfour
18 changes: 10 additions & 8 deletions pdfminer/ascii85.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
import struct

import six #Python 2+3 compatibility
import six # Python 2+3 compatibility


# ascii85decode(data)
Expand All @@ -27,7 +27,7 @@ def ascii85decode(data):
n = b = 0
out = b''
for i in six.iterbytes(data):
c=six.int2byte(i)
c = six.int2byte(i)
if b'!' <= c and c <= b'u':
n += 1
b = b*85+(ord(c)-33)
Expand All @@ -45,9 +45,11 @@ def ascii85decode(data):
break
return out


# asciihexdecode(data)
hex_re = re.compile(b'([a-f\d]{2})', re.IGNORECASE)
trail_re = re.compile(b'^(?:[a-f\d]{2}|\s)*([a-f\d])[\s>]*$', re.IGNORECASE)
hex_re = re.compile(b'([a-f0-9]{2})', re.IGNORECASE)
trail_re = re.compile(b'^(?:[a-f0-9]{2}|[ \t\n\r\f\v])*'
b'([a-f0-9])[ \t\n\r\f\v>]*$', re.IGNORECASE)


def asciihexdecode(data):
Expand All @@ -61,14 +63,14 @@ def asciihexdecode(data):
will behave as if a 0 followed the last digit.
"""
def decode(x):
i=int(x,16)
i = int(x, 16)
return six.int2byte(i)

out=b''
out = b''
for x in hex_re.findall(data):
out+=decode(x)
out += decode(x)

m = trail_re.search(data)
if m:
out+=decode(m.group(1)+b'0')
out += decode(m.group(1)+b'0')
return out
Loading