Skip to content

Commit 3841eae

Browse files
authored
DOC: Tweak some comments (py-pdf#3242)
1 parent b7ae2e5 commit 3841eae

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

pypdf/_doc_common.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,20 +391,18 @@ def recursive_call(
391391
if node["/Type"] == "/Page":
392392
if page_number == mi:
393393
return node, -1
394-
# else
395394
return None, mi + 1
396395
if (page_number - mi) >= ma: # not in nodes below
397396
if node == top:
398397
return top, -1
399-
# else
400398
return None, mi + ma
401399
for idx, kid in enumerate(cast(ArrayObject, node["/Kids"])):
402400
kid = cast(DictionaryObject, kid.get_object())
403401
n, i = recursive_call(kid, mi)
404402
if n is not None: # page has just been found ...
405403
if i < 0: # ... just below!
406404
return node, idx
407-
# else: # ... at lower levels
405+
# ... at lower levels
408406
return n, i
409407
mi = i
410408
raise PyPdfError("Unexpectedly cannot find the node.")
@@ -429,7 +427,7 @@ def get_named_dest_root(self) -> ArrayObject:
429427
names = cast(DictionaryObject, self.root_object[CA.NAMES])
430428
names_ref = names.indirect_reference
431429
if CA.DESTS in names and isinstance(names[CA.DESTS], DictionaryObject):
432-
# 3.6.3 Name Dictionary (PDF spec 1.7)
430+
# §3.6.3 Name Dictionary (PDF spec 1.7)
433431
dests = cast(DictionaryObject, names[CA.DESTS])
434432
dests_ref = dests.indirect_reference
435433
if CA.NAMES in dests:
@@ -527,8 +525,8 @@ def _get_named_destinations(
527525
retval[k__] = dest
528526
return retval
529527

530-
# A select group of relevant field attributes. For the complete list.
531-
# See §12.3.2 of the PDF 1.7 or PDF 2.0 specification.
528+
# A select group of relevant field attributes. For the complete list,
529+
# see §12.3.2 of the PDF 1.7 or PDF 2.0 specification.
532530

533531
def get_fields(
534532
self,
@@ -669,7 +667,7 @@ def _write_field(self, fileobj: Any, field: Any, field_attributes: Any) -> None:
669667
attr_name = field_attributes[attr]
670668
try:
671669
if attr == FA.FT:
672-
# Make the field type value more clear
670+
# Make the field type value clearer
673671
types = {
674672
"/Btn": "Button",
675673
"/Tx": "Text",
@@ -971,7 +969,7 @@ def _build_outline_item(self, node: DictionaryObject) -> Optional[Destination]:
971969
dest, title, outline_item = None, None, None
972970

973971
# title required for valid outline
974-
# § 12.3.3, entries in an outline item dictionary
972+
# §12.3.3, entries in an outline item dictionary
975973
try:
976974
title = cast("str", node["/Title"])
977975
except KeyError:

pypdf/_text_extraction/_layout_mode/_font.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Font:
3838
def __post_init__(self) -> None:
3939
# Type3 fonts that do not specify a "/ToUnicode" mapping cannot be
4040
# reliably converted into character codes unless all named chars
41-
# in /CharProcs map to a standard adobe glyph. See § 9.10.2 of the
41+
# in /CharProcs map to a standard adobe glyph. See §9.10.2 of the
4242
# PDF 1.7 standard.
4343
if self.subtype == "/Type3" and "/ToUnicode" not in self.font_dictionary:
4444
self.interpretable = all(

pypdf/_writer.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,11 @@ class PdfWriter(PdfDocCommon):
158158
159159
incremental: If true, loads the document and set the PdfWriter in incremental mode.
160160
161-
162161
When writing incrementally, the original document is written first and new/modified
163162
content is appended. To be used for signed document/forms to keep signature valid.
164163
165164
full: If true, loads all the objects (always full if incremental = True).
166-
This parameters may allows to load very big PDFs.
165+
This parameter may allow loading large PDFs.
167166
168167
"""
169168

@@ -220,7 +219,7 @@ def __init__(
220219
raise PyPdfError("Invalid type for incremental mode")
221220
self._reader = fileobj # prev content is in _reader.stream
222221
self._header = fileobj.pdf_header.encode()
223-
self._readonly = True # !!!TODO: to be analysed
222+
self._readonly = True # TODO: to be analysed
224223
else:
225224
self._header = b"%PDF-1.3"
226225
self._info_obj = self._add_object(
@@ -253,12 +252,12 @@ def _get_clone_from(
253252
return clone_from
254253

255254
clone_from = _get_clone_from(fileobj, clone_from)
256-
# to prevent overwriting
255+
# To prevent overwriting
257256
self.temp_fileobj = fileobj
258257
self.fileobj = ""
259258
self._with_as_usage = False
260259
self._cloned = False
261-
# The root of our page tree node.
260+
# The root of our page tree node
262261
pages = DictionaryObject()
263262
pages.update(
264263
{
@@ -614,7 +613,7 @@ def _get_page_number_by_indirect(
614613
The page number or None
615614
616615
"""
617-
# to provide same function as in PdfReader
616+
# To provide same function as in PdfReader
618617
if is_null_or_none(indirect_reference):
619618
return None
620619
assert indirect_reference is not None, "mypy"
@@ -1572,7 +1571,7 @@ def metadata(self) -> Optional[DocumentInformation]:
15721571
15731572
Note that some PDF files use (XMP) metadata streams instead of document
15741573
information dictionaries, and these metadata streams will not be
1575-
accessed by this function.
1574+
accessed by this function, but by :meth:`~xmp_metadata`.
15761575
15771576
"""
15781577
return super().metadata
@@ -2658,7 +2657,7 @@ def append(
26582657
import_outline,
26592658
excluded_fields,
26602659
)
2661-
else: # if isinstance(outline_item,str):
2660+
else: # if isinstance(outline_item, str):
26622661
self.merge(
26632662
None,
26642663
fileobj,

pypdf/xmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def _get_text(self, element: XmlElement) -> str:
323323
"""The PDF file version, for example 1.0 or 1.3."""
324324

325325
pdf_producer = property(_getter_single(PDF_NAMESPACE, "Producer"))
326-
"""The name of the tool that created the PDF document."""
326+
"""The name of the tool that saved the document as a PDF."""
327327

328328
xmp_create_date = property(
329329
_getter_single(XMP_NAMESPACE, "CreateDate", _converter_date)

0 commit comments

Comments
 (0)