arxiv.canonical.core module¶
Core interfaces for the canonical record.
-
class
arxiv.canonical.core.
ICanonicalSource
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Interface for source services, used to dereference URIs.
-
class
arxiv.canonical.core.
ICanonicalStorage
(*args, **kwargs)[source]¶ Bases:
arxiv.canonical.core.ICanonicalSource
,arxiv.canonical.core.IManifestStorage
,typing_extensions.Protocol
Interface for services that store the canonical record.
-
load_entry
(key)[source]¶ Load a bitstream entry.
- Parameters
key (
URI
) – Key that identifies the bitsream in the record.- Returns
RecordStream
– The bitstream resource.str – Checksum of the bitstream (URL-safe base64-encoded md5 hash).ß
- Return type
-
store_entry
(ri)[source]¶ Store a bitstream entry in the record.
This method MUST decompress the content of the entry if it is gzipped (as is sometimes the case in the classic system) and update the
CanonicalFile
(ri.record.stream.domain
).- Parameters
ri (
IStorableEntry
) – A storable bitstream.- Return type
None
-
-
class
arxiv.canonical.core.
IEventStream
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Interface for the canonical event stream.
-
class
arxiv.canonical.core.
IManifestStorage
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Manifest protocol.
This could conceivably be stored separately from the canonical record content, so it is defined separately.
-
class
arxiv.canonical.core.
IPreservationAPI
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Interface for the daily preservation record API.
-
class
arxiv.canonical.core.
IRegisterAPI
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Interface for the canonical register API.
-
class
arxiv.canonical.core.
IStorableEntry
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Minimal interface for a bitstream interface that can be stored.
Services that implement
ICanonicalStorage
can assume that the attributes of this interface are available on objects passed for storing.-
name
= None¶ Name of the entry.
-
property
record
¶ Reference to a
RecordEntry
.- Return type
RecordEntry
[~_EDomain]
-
-
arxiv.canonical.core.
Month
¶ alias of
builtins.int
-
arxiv.canonical.core.
Selector
= typing.Union[int, typing.Tuple[int, int], datetime.date]¶ A selector can refer to a year, month, or a specific date.
-
arxiv.canonical.core.
Year
¶ alias of
builtins.int
-
arxiv.canonical.core.
YearMonth
¶ alias of
typing.Tuple
-
arxiv.canonical.core.
dereference
(sources, uri)[source]¶ Dereference an URI using a set of available sources.
Sources are checked one at a time for ability to resolve the URI. When one is found, the URI is loaded.
- Parameters
sources (sequence) – Items are content sources that should conform to
ICanonicalSource
. They will be tried in the order provided.uri (
URI
) – URI to dereference.
- Returns
BytesIO object.
- Return type
io
- Raises
RuntimeError – Raised when the URI cannot be resolved.
- Return type