Skip to content

Commit

Permalink
STY: Apply black/isort
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Jun 4, 2022
1 parent 66ecb2a commit e853ec1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 21 deletions.
44 changes: 34 additions & 10 deletions PyPDF2/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
)

from ._utils import (
deprecate_no_replacement,
deprecate_with_replacement,
CompressedTransformationMatrix,
TransformationMatrixType,
b_,
deprecate_no_replacement,
deprecate_with_replacement,
matrix_multiply,
)
from .constants import PageAttributes as PG
Expand Down Expand Up @@ -600,7 +600,10 @@ def mergeTransformedPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeTransformedPage(page2, ctm)", "page2.add_transformation(ctm); page.merge_page(page2)")
deprecate_with_replacement(
"page.mergeTransformedPage(page2, ctm)",
"page2.add_transformation(ctm); page.merge_page(page2)",
)
if isinstance(ctm, Transformation):
ctm = ctm.ctm
ctm = cast(CompressedTransformationMatrix, ctm)
Expand Down Expand Up @@ -630,7 +633,10 @@ def mergeScaledPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeScaledPage(page2, scale, expand)", "page2.add_transformation(Transformation().scale(scale)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeScaledPage(page2, scale, expand)",
"page2.add_transformation(Transformation().scale(scale)); page.merge_page(page2, expand)",
)
op = Transformation().scale(scale, scale)
self.mergeTransformedPage(page2, op, expand)

Expand All @@ -651,7 +657,10 @@ def mergeRotatedPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeRotatedPage(page2, rotation, expand)", "page2.add_transformation(Transformation().rotate(rotation)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeRotatedPage(page2, rotation, expand)",
"page2.add_transformation(Transformation().rotate(rotation)); page.merge_page(page2, expand)",
)
op = Transformation().rotate(rotation)
self.mergeTransformedPage(page2, op, expand)

Expand All @@ -673,7 +682,10 @@ def mergeTranslatedPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeTranslatedPage(page2, tx, ty, expand)", "page2.add_transformation(Transformation().translate(tx, ty)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeTranslatedPage(page2, tx, ty, expand)",
"page2.add_transformation(Transformation().translate(tx, ty)); page.merge_page(page2, expand)",
)
op = Transformation().translate(tx, ty)
self.mergeTransformedPage(page2, op, expand)

Expand Down Expand Up @@ -701,7 +713,10 @@ def mergeRotatedTranslatedPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeRotatedTranslatedPage(page2, rotation, tx, ty, expand)", "page2.add_transformation(Transformation().rotate(rotation).translate(tx, ty)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeRotatedTranslatedPage(page2, rotation, tx, ty, expand)",
"page2.add_transformation(Transformation().rotate(rotation).translate(tx, ty)); page.merge_page(page2, expand)",
)
op = Transformation().translate(-tx, -ty).rotate(rotation).translate(tx, ty)
return self.mergeTransformedPage(page2, op, expand)

Expand All @@ -723,7 +738,10 @@ def mergeRotatedScaledPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeRotatedScaledPage(page2, rotation, scale, expand)", "page2.add_transformation(Transformation().rotate(rotation).scale(scale)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeRotatedScaledPage(page2, rotation, scale, expand)",
"page2.add_transformation(Transformation().rotate(rotation).scale(scale)); page.merge_page(page2, expand)",
)
op = Transformation().rotate(rotation).scale(scale, scale)
self.mergeTransformedPage(page2, op, expand)

Expand Down Expand Up @@ -751,7 +769,10 @@ def mergeScaledTranslatedPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeScaledTranslatedPage(page2, scale, tx, ty, expand)", "page2.add_transformation(Transformation().scale(scale).translate(tx, ty)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeScaledTranslatedPage(page2, scale, tx, ty, expand)",
"page2.add_transformation(Transformation().scale(scale).translate(tx, ty)); page.merge_page(page2, expand)",
)
op = Transformation().scale(scale, scale).translate(tx, ty)
return self.mergeTransformedPage(page2, op, expand)

Expand Down Expand Up @@ -782,7 +803,10 @@ def mergeRotatedScaledTranslatedPage(
Use :meth:`add_transformation` and :meth:`merge_page` instead.
"""
deprecate_with_replacement("page.mergeRotatedScaledTranslatedPage(page2, rotation, tx, ty, expand)", "page2.add_transformation(Transformation().rotate(rotation).scale(scale)); page.merge_page(page2, expand)")
deprecate_with_replacement(
"page.mergeRotatedScaledTranslatedPage(page2, rotation, tx, ty, expand)",
"page2.add_transformation(Transformation().rotate(rotation).scale(scale)); page.merge_page(page2, expand)",
)
op = Transformation().rotate(rotation).scale(scale, scale).translate(tx, ty)
self.mergeTransformedPage(page2, op, expand)

Expand Down
16 changes: 11 additions & 5 deletions PyPDF2/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@
from ._page import PageObject, _VirtualList
from ._security import RC4_encrypt, _alg33_1, _alg34, _alg35
from ._utils import (
deprecate_no_replacement,
deprecate_with_replacement,
StrByteType,
StreamType,
b_,
deprecate_no_replacement,
deprecate_with_replacement,
ord_,
read_non_whitespace,
read_until_whitespace,
Expand Down Expand Up @@ -382,7 +382,9 @@ def getPage(self, pageNumber: int) -> PageObject:
Use :code:`reader.pages[pageNumber]` instead.
"""
deprecate_with_replacement("reader.getPage(pageNumber)", "reader.pages[pageNumber]")
deprecate_with_replacement(
"reader.getPage(pageNumber)", "reader.pages[pageNumber]"
)
return self._get_page(pageNumber)

def _get_page(self, page_number: int) -> PageObject:
Expand Down Expand Up @@ -746,7 +748,9 @@ def getDestinationPageNumber(self, destination: Destination) -> int:
Use :meth:`get_destination_page_number` instead.
"""
deprecate_with_replacement("getDestinationPageNumber", "get_destination_page_number")
deprecate_with_replacement(
"getDestinationPageNumber", "get_destination_page_number"
)
return self.get_destination_page_number(destination)

def _build_destination(
Expand Down Expand Up @@ -1155,7 +1159,9 @@ def cacheGetIndirectObject(
Use :meth:`cache_get_indirect_object` instead.
"""
deprecate_with_replacement("cacheGetIndirectObject", "cache_get_indirect_object")
deprecate_with_replacement(
"cacheGetIndirectObject", "cache_get_indirect_object"
)
return self.cache_get_indirect_object(generation, idnum)

def cache_indirect_object(
Expand Down
22 changes: 16 additions & 6 deletions PyPDF2/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from ._page import PageObject, _VirtualList
from ._reader import PdfReader
from ._security import _alg33, _alg34, _alg35
from ._utils import deprecate_with_replacement, StreamType, b_
from ._utils import StreamType, b_, deprecate_with_replacement
from .constants import CatalogAttributes as CA
from .constants import Core as CO
from .constants import EncryptionDictAttributes as ED
Expand Down Expand Up @@ -564,7 +564,9 @@ def updatePageFormFieldValues(
Use :meth:`update_page_form_field_values` instead.
"""
deprecate_with_replacement("updatePageFormFieldValues", "update_page_form_field_values")
deprecate_with_replacement(
"updatePageFormFieldValues", "update_page_form_field_values"
)
return self.update_page_form_field_values(page, fields, flags)

def clone_reader_document_root(self, reader: PdfReader) -> None:
Expand All @@ -582,7 +584,9 @@ def cloneReaderDocumentRoot(self, reader: PdfReader) -> None:
Use :meth:`clone_reader_document_root` instead.
"""
deprecate_with_replacement("cloneReaderDocumentRoot", "clone_reader_document_root")
deprecate_with_replacement(
"cloneReaderDocumentRoot", "clone_reader_document_root"
)
self.clone_reader_document_root(reader)

def clone_document_from_reader(
Expand Down Expand Up @@ -615,7 +619,9 @@ def cloneDocumentFromReader(
Use :meth:`clone_document_from_reader` instead.
"""
deprecate_with_replacement("cloneDocumentFromReader", "clone_document_from_reader")
deprecate_with_replacement(
"cloneDocumentFromReader", "clone_document_from_reader"
)
self.clone_document_from_reader(reader, after_page_append)

def encrypt(
Expand Down Expand Up @@ -1139,7 +1145,9 @@ def addNamedDestinationObject(self, dest: PdfObject) -> IndirectObject:
Use :meth:`add_named_destination_object` instead.
"""
deprecate_with_replacement("addNamedDestinationObject", "add_named_destination_object")
deprecate_with_replacement(
"addNamedDestinationObject", "add_named_destination_object"
)
return self.add_named_destination_object(dest)

def add_named_destination(self, title: str, pagenum: int) -> IndirectObject:
Expand Down Expand Up @@ -1583,7 +1591,9 @@ def setPageLayout(self, layout: LayoutType) -> None:
Use :py:attr:`page_layout` instead.
"""
deprecate_with_replacement("writer.setPageLayout(val)", "writer.page_layout = val")
deprecate_with_replacement(
"writer.setPageLayout(val)", "writer.page_layout = val"
)
return self._set_page_layout(layout)

@property
Expand Down

0 comments on commit e853ec1

Please sign in to comment.