Skip to content

Commit 92ca9f4

Browse files
committed
Resolve dictionary key override
Key "dictkey_desc" was defined twice, such that places expecting a "description" instead received "descender". Added a different key, "dictkey_descr" with a string value of "description".
1 parent 13752eb commit 92ca9f4

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

docs/document.rst

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,21 +1551,19 @@ For details on **embedded files** refer to Appendix 3.
15511551
:rtype: dict
15521552
:returns: a dictionary with the following keys:
15531553

1554-
* *name* -- (*str*) name under which this entry is stored
1555-
* *filename* -- (*str*) filename
1556-
* *ufilename* -- (*unicode*) filename
1557-
* *desc* -- (*str*) description
1558-
* *size* -- (*int*) original file size
1559-
* *length* -- (*int*) compressed file length
1560-
* *creationDate* -- *(New in v1.18.13)* (*str*) date-time of item creation in PDF format
1561-
* *modDate* -- *(New in v1.18.13)* (*str*) date-time of last change in PDF format
1562-
* *collection* -- *(New in v1.18.13)* (*int*) :data:`xref` of the associated PDF portfolio item if any, else zero.
1563-
* *checksum* -- *(New in v1.18.13)* (*str*) a hashcode of the stored file content as a hexadecimal string. Should be MD5 according to PDF specifications, but be prepared to see other hashing algorithms.
1554+
* ``name`` -- (*str*) name under which this entry is stored
1555+
* ``filename`` -- (*str*) filename
1556+
* ``ufilename`` -- (*unicode*) filename
1557+
* ``description`` -- (*str*) description
1558+
* ``size`` -- (*int*) original file size
1559+
* ``length`` -- (*int*) compressed file length
1560+
* ``creationDate`` -- (*str*) date-time of item creation in PDF format
1561+
* ``modDate`` -- (*str*) date-time of last change in PDF format
1562+
* ``collection`` -- (*int*) :data:`xref` of the associated PDF portfolio item if any, else zero.
1563+
* ``checksum`` -- (*str*) a hashcode of the stored file content as a hexadecimal string. Should be MD5 according to PDF specifications, but be prepared to see other hashing algorithms.
15641564

15651565
.. method:: embfile_names()
15661566

1567-
* New in v1.14.16
1568-
15691567
PDF only: Return a list of embedded file names. The sequence of the names equals the physical sequence in the document.
15701568

15711569
:rtype: list

src/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def file_info(self):
912912
size = mupdf.pdf_to_int(o)
913913

914914
res[ dictkey_filename] = JM_EscapeStrFromStr(filename)
915-
res[ dictkey_desc] = JM_UnicodeFromStr(desc)
915+
res[ dictkey_descr] = JM_UnicodeFromStr(desc)
916916
res[ dictkey_length] = length
917917
res[ dictkey_size] = size
918918
return res
@@ -3255,7 +3255,7 @@ def _embfile_info(self, idx, infodict):
32553255
infodict[dictkey_ufilename] = JM_EscapeStrFromStr(name)
32563256

32573257
name = mupdf.pdf_to_text_string(mupdf.pdf_dict_get(o, PDF_NAME('Desc')))
3258-
infodict[dictkey_desc] = JM_UnicodeFromStr(name)
3258+
infodict[dictkey_descr] = JM_UnicodeFromStr(name)
32593259

32603260
len_ = -1
32613261
DL = -1
@@ -13668,7 +13668,7 @@ class EmptyFileError(FileDataError):
1366813668
dictkey_cs_name = "cs-name"
1366913669
dictkey_da = "da"
1367013670
dictkey_dashes = "dashes"
13671-
dictkey_desc = "desc"
13671+
dictkey_descr = "description"
1367213672
dictkey_desc = "descender"
1367313673
dictkey_dir = "dir"
1367413674
dictkey_effect = "effect"

tests/test_annots.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ def test_file_info():
343343
print(f'{file_info=}')
344344
results.append(file_info)
345345
assert results == [
346-
{'filename': 'example.pdf', 'descender': '', 'length': 8416, 'size': 8992},
347-
{'filename': 'photo1.jpeg', 'descender': '', 'length': 10154, 'size': 8012},
346+
{'filename': 'example.pdf', 'description': '', 'length': 8416, 'size': 8992},
347+
{'filename': 'photo1.jpeg', 'description': '', 'length': 10154, 'size': 8012},
348348
]
349349

350350
def test_3131():

0 commit comments

Comments
 (0)