zabgrab.services.records¶
What a file’s metadata records about its items beyond the data.
zabgrab migrate marks items as retired, gives moved items a history of their
earlier servers and IDs, and logs each migration (see
zabgrab.services.migrate). These helpers read those records for update,
info and export, and carry them into the groups and files written later.
Items are identified by their server’s URL and item ID, as in the file
(Identity).
Module Attributes
its server's URL and its item ID. |
|
The item entry keys that describe the item's past rather than one fetch, so they're kept when the item is written again (by |
Functions
|
List the items a group's metadata says |
|
Carry the migration log and items' histories into a new group's metadata. |
|
Copy items' histories and retired marks into new item entries. |
|
Get the identity of an item entry in the metadata. |
|
Check whether an item entry is marked as retired. |
|
Get the latest metadata entry of every item any group lists. |
|
Find the items that are retired (as their latest entries say). |
Classes
|
Anything with a fetch group's metadata. |
- zabgrab.services.records.Identity¶
its server’s URL and its item ID.
- Type:
An item as a file identifies it
- zabgrab.services.records.CARRIED = ('history', 'retired')¶
The item entry keys that describe the item’s past rather than one fetch, so they’re kept when the item is written again (by
updateorexport).
- class zabgrab.services.records.HasMetadata(*args, **kwargs)[source]¶
Bases:
ProtocolAnything with a fetch group’s metadata.
- zabgrab.services.records.identity(entry)[source]¶
Get the identity of an item entry in the metadata.
- zabgrab.services.records.is_retired(entry)[source]¶
Check whether an item entry is marked as retired.
- zabgrab.services.records.active_entries(metadata)[source]¶
List the items a group’s metadata says
updateshould fetch next.These are the group’s items that aren’t retired, then any items brought back with
migrate --unretireafter the group stopped listing them (itsresumeentries).- Parameters:
metadata (mapping) – A group’s metadata (normally the last group’s).
- Returns:
list of dict – The item entries, each item once.
- Return type:
Examples
>>> metadata = { ... "items": [ ... {"server": "https://z", "itemid": 1}, ... {"server": "https://z", "itemid": 2, "retired": {"at": "2026"}}, ... ], ... "resume": [{"server": "https://z", "itemid": 3}], ... } >>> [entry["itemid"] for entry in active_entries(metadata)] [1, 3]
- zabgrab.services.records.latest_entries(groups)[source]¶
Get the latest metadata entry of every item any group lists.
- zabgrab.services.records.retired_items(groups)[source]¶
Find the items that are retired (as their latest entries say).
- zabgrab.services.records.carry_records(entries, records)[source]¶
Copy items’ histories and retired marks into new item entries.
- Parameters:
entries (iterable of dict) – The new entries (changed in place).
records (mapping of Identity to mapping) – Earlier entries for the same items (e.g. from
latest_entries()).
- Return type:
None
- zabgrab.services.records.carry_forward(previous, metadata)[source]¶
Carry the migration log and items’ histories into a new group’s metadata.
updatewrites each group’s metadata afresh; this keeps the file’s latest group a complete record of its items’ pasts. Retired marks aren’t carried, sinceupdatedoesn’t fetch retired items.- Parameters:
previous (mapping) – The metadata of the group being continued.
metadata (dict) – The new group’s metadata (changed in place).
- Return type:
None