| 1 | ```{caution} |
| 2 | This API is not finalised, and may change in a patch version. |
| 3 | ``` |
| 4 | |
| 5 | # `installer.records` |
| 6 | |
| 7 | ```{eval-rst} |
| 8 | .. automodule:: installer.records |
| 9 | ``` |
| 10 | |
| 11 | ## Example |
| 12 | |
| 13 | ```{doctest} pycon |
| 14 | >>> from installer.records import parse_record_file, RecordEntry |
| 15 | >>> lines = [ |
| 16 | ... "file.py,sha256=AVTFPZpEKzuHr7OvQZmhaU3LvwKz06AJw8mT\\_pNh2yI,3144", |
| 17 | ... "distribution-1.0.dist-info/RECORD,,", |
| 18 | ... ] |
| 19 | >>> records = parse_record_file(lines) |
| 20 | >>> li = list(records) |
| 21 | >>> len(li) |
| 22 | 2 |
| 23 | >>> record_tuple = li[0] |
| 24 | >>> record_tuple |
| 25 | ('file.py', 'sha256=AVTFPZpEKzuHr7OvQZmhaU3LvwKz06AJw8mT\\_pNh2yI', '3144') |
| 26 | >>> record = RecordEntry.from_elements(*record_tuple) |
| 27 | >>> record |
| 28 | RecordEntry(path='file.py', hash_=Hash(name='sha256', value='AVTFPZpEKzuHr7OvQZmhaU3LvwKz06AJw8mT\\_pNh2yI'), size=3144) |
| 29 | >>> record.path |
| 30 | 'file.py' |
| 31 | >>> record.hash_ |
| 32 | Hash(name='sha256', value='AVTFPZpEKzuHr7OvQZmhaU3LvwKz06AJw8mT\\_pNh2yI') |
| 33 | >>> record.size |
| 34 | 3144 |
| 35 | >>> record.validate(b"...") |
| 36 | False |
| 37 | ``` |
| 38 | |
| 39 | ## Reference |
| 40 | |
| 41 | ```{eval-rst} |
| 42 | .. autofunction:: installer.records.parse_record_file |
| 43 | |
| 44 | .. autoclass:: installer.records.RecordEntry() |
| 45 | :special-members: __init__ |
| 46 | :members: |
| 47 | |
| 48 | .. autoclass:: installer.records.Hash() |
| 49 | :special-members: __init__ |
| 50 | :members: |
| 51 | ``` |