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: Move is_encrypted below __init__ #2659

Merged
merged 1 commit into from
May 20, 2024
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
4 changes: 2 additions & 2 deletions pypdf/_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _info(self) -> Optional[DictionaryObject]:
Provide access to "/Info". standardized with PdfWriter.

Returns:
/Info Dictionary ; None if the entry does not exists
/Info Dictionary; None if the entry does not exist
"""
info = self.trailer.get(TK.INFO, None)
if info is None:
Expand All @@ -183,7 +183,7 @@ def _ID(self) -> Optional[ArrayObject]:
Provide access to "/ID". standardized with PdfWriter.

Returns:
/ID array ; None if the entry does not exists
/ID array; None if the entry does not exist
"""
id = self.trailer.get(TK.ID, None)
return None if id is None else cast(ArrayObject, id.get_object())
Expand Down
24 changes: 12 additions & 12 deletions pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,6 @@ class PdfWriter(PdfDocCommon):
Typically data is added from a :class:`PdfReader<pypdf.PdfReader>`.
"""

# for commonality
@property
def is_encrypted(self) -> bool:
"""
Read-only boolean property showing whether this PDF file is encrypted.

Note that this property, if true, will remain true even after the
:meth:`decrypt()<pypdf.PdfReader.decrypt>` method is called.
"""
return False

def __init__(
self,
fileobj: Union[None, PdfReader, StrByteType, Path] = "",
Expand Down Expand Up @@ -252,6 +241,17 @@ def _get_clone_from(
self._encrypt_entry: Optional[DictionaryObject] = None
self._ID: Union[ArrayObject, None] = None

# for commonality
@property
def is_encrypted(self) -> bool:
"""
Read-only boolean property showing whether this PDF file is encrypted.

Note that this property, if true, will remain true even after the
:meth:`decrypt()<pypdf.PdfReader.decrypt>` method is called.
"""
return False

@property
def root_object(self) -> DictionaryObject:
"""
Expand Down Expand Up @@ -2471,7 +2471,7 @@ def merge(
elif isinstance(dest["/Page"], NullObject):
pass
elif isinstance(dest["/Page"], int):
# the page reference is a page number normally not iaw Pdf Reference
# the page reference is a page number normally not a PDF Reference
# page numbers as int are normally accepted only in external goto
p = reader.pages[dest["/Page"]]
assert p.indirect_reference is not None
Expand Down
Loading