Skip to content
Merged
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: 0 additions & 2 deletions pypdf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ._crypt_providers import crypt_provider
from ._doc_common import DocumentInformation
from ._encryption import PasswordType
from ._merger import PdfMerger
from ._page import PageObject, Transformation
from ._reader import PdfReader
from ._text_extraction import mult
Expand Down Expand Up @@ -39,7 +38,6 @@
"PageRange",
"PaperSize",
"PasswordType",
"PdfMerger",
"PdfReader",
"PdfWriter",
"Transformation",
Expand Down
4 changes: 2 additions & 2 deletions pypdf/_doc_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from ._page import PageObject, _VirtualList
from ._page_labels import index2label as page_index2page_label
from ._utils import (
deprecate_with_replacement,
deprecation_with_replacement,
logger_warning,
parse_iso8824_date,
)
Expand Down Expand Up @@ -1259,7 +1259,7 @@ def decode_permissions(
self, permissions_code: int
) -> dict[str, bool]: # pragma: no cover
"""Take the permissions as an integer, return the allowed access."""
deprecate_with_replacement(
deprecation_with_replacement(
old_name="decode_permissions",
new_name="user_access_permissions",
removed_in="5.0.0",
Expand Down
42 changes: 0 additions & 42 deletions pypdf/_merger.py

This file was deleted.

91 changes: 3 additions & 88 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@
StrByteType,
StreamType,
_get_max_pdf_version_header,
deprecate,
deprecate_no_replacement,
deprecation_with_replacement,
deprecation_no_replacement,
logger_warning,
)
from .constants import AnnotationDictionaryAttributes as AA
Expand Down Expand Up @@ -377,12 +375,12 @@ def xmp_metadata(self, value: Optional[XmpInformation]) -> None:

@property
def with_as_usage(self) -> bool:
deprecate_no_replacement("with_as_usage", "6.0")
deprecation_no_replacement("with_as_usage", "5.0")
return self._with_as_usage

@with_as_usage.setter
def with_as_usage(self, value: bool) -> None:
deprecate_no_replacement("with_as_usage", "6.0")
deprecation_no_replacement("with_as_usage", "5.0")
self._with_as_usage = value

def __enter__(self) -> "PdfWriter":
Expand Down Expand Up @@ -1426,10 +1424,6 @@ def write_stream(self, stream: StreamType) -> None:
"It may not be written to correctly.",
__name__,
)
# deprecated to be removed in pypdf 6.0.0 :
# if not self._root:
# self._root = self._add_object(self._root_object)
# self._sweep_indirect_references(self._root)
self._resolve_links()

if self.incremental:
Expand Down Expand Up @@ -1754,74 +1748,6 @@ def replace_in_obj(
for i in compress(range(len(self._objects)), orphans):
self._objects[i] = None

def _sweep_indirect_references(
self,
root: Union[
ArrayObject,
BooleanObject,
DictionaryObject,
FloatObject,
IndirectObject,
NameObject,
PdfObject,
NumberObject,
TextStringObject,
NullObject,
],
) -> None: # deprecated
"""
Resolving any circular references to Page objects.

Circular references to Page objects can arise when objects such as
annotations refer to their associated page. If these references are not
properly handled, the PDF file will contain multiple copies of the same
Page object. To address this problem, Page objects store their original
object reference number. This method adds the reference number of any
circularly referenced Page objects to an external reference map. This
ensures that self-referencing trees reference the correct new object
location, rather than copying in a new copy of the Page object.

Args:
root: The root of the PDF object tree to sweep.

"""
deprecate(
"_sweep_indirect_references has been removed, please report to dev team if this warning is observed",
)

def _resolve_indirect_object(
self, data: IndirectObject
) -> IndirectObject: # deprecated
"""
Resolves an indirect object to an indirect object in this PDF file.

If the input indirect object already belongs to this PDF file, it is
returned directly. Otherwise, the object is retrieved from the input
object's PDF file using the object's ID number and generation number. If
the object cannot be found, a warning is logged and a `NullObject` is
returned.

If the object is not already in this PDF file, it is added to the file's
list of objects and assigned a new ID number and generation number of 0.
The hash value of the object is then added to the `_idnum_hash`
dictionary, with the corresponding `IndirectObject` reference as the
value.

Args:
data: The `IndirectObject` to resolve.

Returns:
The resolved `IndirectObject` in this PDF file.

Raises:
ValueError: If the input stream is closed.

"""
deprecate(
"_resolve_indirect_object has been removed, please report to dev team if this warning is observed",
)
return IndirectObject(0, 0, self)

def get_reference(self, obj: PdfObject) -> IndirectObject:
idnum = self._objects.index(obj) + 1
ref = IndirectObject(idnum, 0, self)
Expand Down Expand Up @@ -3255,17 +3181,6 @@ def find_outline_item(
else:
return None

def find_bookmark(
self,
outline_item: dict[str, Any],
root: Optional[OutlineType] = None,
) -> None: # deprecated
"""
.. deprecated:: 2.9.0
Use :meth:`find_outline_item` instead.
"""
deprecation_with_replacement("find_bookmark", "find_outline_item", "5.0.0")

def reset_translation(
self, reader: Union[None, PdfReader, IndirectObject] = None
) -> None:
Expand Down
9 changes: 0 additions & 9 deletions pypdf/annotations/_markup_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from abc import ABC
from typing import Any, Optional, Union

from .._utils import deprecation_with_replacement
from ..constants import AnnotationFlag
from ..generic import ArrayObject, DictionaryObject
from ..generic._base import (
Expand Down Expand Up @@ -217,10 +216,6 @@ def __init__(
interior_color: Optional[str] = None,
**kwargs: Any,
) -> None:
if "interiour_color" in kwargs:
deprecation_with_replacement("interiour_color", "interior_color", "5.0.0")
interior_color = kwargs["interiour_color"]
del kwargs["interiour_color"]
super().__init__(**kwargs)
self.update(
{
Expand Down Expand Up @@ -269,10 +264,6 @@ def __init__(
interior_color: Optional[str] = None,
**kwargs: Any,
) -> None:
if "interiour_color" in kwargs:
deprecation_with_replacement("interiour_color", "interior_color", "5.0.0")
interior_color = kwargs["interiour_color"]
del kwargs["interiour_color"]
super().__init__(**kwargs)

self.update(
Expand Down
8 changes: 0 additions & 8 deletions pypdf/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ class Resources:
PROPERTIES = "/Properties" # dictionary, optional


class Ressources: # deprecated
"""
Use :class: `Resources` instead.

.. deprecated:: 5.0.0
"""


class PagesAttributes:
"""§7.7.3.2 of the 1.7 and 2.0 reference."""

Expand Down
40 changes: 5 additions & 35 deletions pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@
from ._codecs._codecs import LzwCodec as _LzwCodec
from ._utils import (
WHITESPACES_AS_BYTES,
deprecate,
deprecate_with_replacement,
deprecation_no_replacement,
deprecation_with_replacement,
logger_warning,
)
from .constants import CcittFaxDecodeParameters as CCITT
Expand All @@ -61,7 +59,7 @@
from .constants import ImageAttributes as IA
from .constants import LzwFilterParameters as LZW
from .constants import StreamAttributes as SA
from .errors import DependencyError, DeprecationError, PdfReadError, PdfStreamError
from .errors import DependencyError, PdfReadError, PdfStreamError
from .generic import (
ArrayObject,
BooleanObject,
Expand Down Expand Up @@ -145,9 +143,6 @@ def decode(
PdfReadError:

"""
if isinstance(decode_parms, ArrayObject):
raise DeprecationError("decode_parms as ArrayObject is deprecated")

str_data = decompress(data)
predictor = 1

Expand Down Expand Up @@ -420,7 +415,7 @@ def decode(self) -> bytes:
return _LzwCodec().decode(self.data)

@staticmethod
def _decodeb(
def decode(
data: bytes,
decode_parms: Optional[DictionaryObject] = None,
**kwargs: Any,
Expand All @@ -439,27 +434,6 @@ def _decodeb(
# decode_parms is unused here
return LZWDecode.Decoder(data).decode()

@staticmethod
def decode(
data: bytes,
decode_parms: Optional[DictionaryObject] = None,
**kwargs: Any,
) -> str: # deprecated
"""
Decode an LZW encoded data stream.

Args:
data: ``bytes`` or ``str`` text to decode.
decode_parms: a dictionary of parameter values.

Returns:
decoded data.

"""
# decode_parms is unused here
deprecate("LZWDecode.decode will return bytes instead of str in pypdf 6.0.0")
return LZWDecode.Decoder(data).decode().decode("latin-1")


class ASCII85Decode:
"""Decodes string ASCII85-encoded data into a byte format."""
Expand Down Expand Up @@ -568,7 +542,7 @@ def __create_old_class_instance(
columns: int = 0,
rows: int = 0
) -> CCITTParameters:
deprecate_with_replacement("CCITParameters", "CCITTParameters", "6.0.0")
deprecation_with_replacement("CCITParameters", "CCITTParameters", "6.0.0")
return CCITTParameters(K, columns, rows)


Expand Down Expand Up @@ -619,10 +593,6 @@ def decode(
height: int = 0,
**kwargs: Any,
) -> bytes:
if isinstance(decode_parms, ArrayObject): # deprecated
deprecation_no_replacement(
"decode_parms being an ArrayObject", removed_in="3.15.5"
)
params = CCITTFaxDecode._get_parameters(decode_parms, height)

img_size = len(data)
Expand Down Expand Up @@ -772,7 +742,7 @@ def decode_stream_data(stream: Any) -> bytes:
elif filter_name in (FT.ASCII_85_DECODE, FTA.A85):
data = ASCII85Decode.decode(data)
elif filter_name in (FT.LZW_DECODE, FTA.LZW):
data = LZWDecode._decodeb(data, params)
data = LZWDecode.decode(data, params)
elif filter_name in (FT.FLATE_DECODE, FTA.FL):
data = FlateDecode.decode(data, params)
elif filter_name in (FT.RUN_LENGTH_DECODE, FTA.RL):
Expand Down
Loading
Loading