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

STY: Remove star imports #741

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- name: Test with flake8
run: |
flake8 . --ignore E,F,I,SIM,C,PT,N,ASS,A,P,R,W
flake8 . --ignore E,I,SIM,C,PT,N,ASS,A,P,R,W,F401,F841
if: matrix.python-version != '2.7'

- name: Test with pytest
Expand Down
14 changes: 6 additions & 8 deletions PyPDF2/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@
__author__ = "Mathieu Fenniak"
__author_email__ = "[email protected]"

import codecs
import decimal
import re
from .utils import readNonWhitespace, RC4_encrypt, skipOverComment
from .utils import b_, u_, chr_, ord_
from .utils import PdfStreamError
import warnings
from . import filters
from . import utils
import decimal
import codecs

from . import filters, utils
from .utils import (PdfStreamError, RC4_encrypt, b_, chr_, ord_,
readNonWhitespace, skipOverComment, u_)

ObjectPrefix = b_('/<[tf(n%')
NumberSigns = b_('+-')
Expand Down Expand Up @@ -631,7 +630,6 @@ def readFromStream(stream, pdf):
# we found it by looking back one character further.
data["__streamdata__"] = data["__streamdata__"][:-1]
else:
if debug: print(("E", e, ndstream, debugging.toHex(end)))
stream.seek(pos, 0)
raise utils.PdfReadError("Unable to find 'endstream' marker after stream at byte %s." % utils.hexStr(stream.tell()))
else:
Expand Down
12 changes: 8 additions & 4 deletions PyPDF2/merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

from .generic import *
from .utils import isString, str_
from .pdf import PdfFileReader, PdfFileWriter
from .pagerange import PageRange
from sys import version_info

from .generic import (ArrayObject, Bookmark, Destination, DictionaryObject,
Field, FloatObject, NameObject, NullObject, NumberObject,
TextStringObject, TreeObject, createStringObject)
from .pagerange import PageRange
from .pdf import PdfFileReader, PdfFileWriter
from .utils import isString, str_

if version_info < ( 3, 0 ):
from cStringIO import StringIO
StreamIO = StringIO
Expand Down
24 changes: 15 additions & 9 deletions PyPDF2/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
__maintainer__ = "Phaseit, Inc."
__maintainer_email = "[email protected]"

import string
import math
import string
import struct
import sys
import uuid
from sys import version_info

if version_info < ( 3, 0 ):
from cStringIO import StringIO
else:
Expand All @@ -57,13 +58,18 @@
else:
from io import BytesIO

from . import filters
from . import utils
import warnings
import codecs
from .generic import *
from .utils import readNonWhitespace, readUntilWhitespace, ConvertFunctionsToVirtualList
from .utils import isString, b_, u_, ord_, str_, formatWarning
import warnings

from . import filters, utils
from .generic import (ArrayObject, BooleanObject, ByteStringObject,
DecodedStreamObject, Destination, DictionaryObject,
Field, FloatObject, IndirectObject, NameObject,
NullObject, NumberObject, RectangleObject, StreamObject,
TextStringObject, TreeObject, createStringObject,
readObject)
from .utils import (ConvertFunctionsToVirtualList, b_, formatWarning, isString,
ord_, readNonWhitespace, readUntilWhitespace, str_, u_)

if version_info < ( 2, 4 ):
from sets import ImmutableSet as frozenset
Expand All @@ -72,7 +78,6 @@
from md5 import md5
else:
from hashlib import md5
import uuid


class PdfFileWriter(object):
Expand Down Expand Up @@ -406,7 +411,8 @@ def encrypt(self, user_pwd, owner_pwd = None, use_128bit = True):
encryption. When false, 40bit encryption will be used. By default,
this flag is on.
"""
import time, random
import random
import time
if owner_pwd == None:
owner_pwd = user_pwd
if use_128bit:
Expand Down
4 changes: 2 additions & 2 deletions PyPDF2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

bytes_type = type(bytes()) # Works the same in Python 2.X and 3.X
string_type = getattr(builtins, "unicode", str)
int_types = (int, long) if sys.version_info[0] < 3 else (int,)
int_types = (int, long) if sys.version_info[0] < 3 else (int,) # noqa


# Make basic type tests more consistent
Expand Down Expand Up @@ -252,7 +252,7 @@ def b_(s):

def u_(s):
if sys.version_info[0] < 3:
return unicode(s, 'unicode_escape')
return unicode(s, 'unicode_escape') # noqa
else:
return s

Expand Down