arxiv.canonical.register package¶
Register for the canonical record.
This module implements the high-level API for the arXiv canonical record. It
orchestrates the classes in arxiv.canonical.domain
,
arxiv.canonical.record
, and arxiv.canonical.integrity
to
implement reading from and writing to the record.
-
class
arxiv.canonical.register.
Base
(name, domain, record, integrity, members=None)[source]¶ Bases:
typing.Generic
Generic base class for all register classes.
This defines the abstract structure of a register class. It specifies thatpecifically that instances of a register class are composed of a domain object, a record object, an integrity object, and a set of members. This allows us to define register classes that align domain, record, and integrity classes at a specific level of the record hierarchy.
-
domain
= None¶ The domain object on a register instance.
-
domain_type
= None¶ The type of the domain object on a register instance.
-
integrity
= None¶ The integrity object on a register instance.
-
integrity_type
= None¶ The type of the integrity object on a register instance.
-
iter_members
()[source]¶ Get an iterator over members in this register.
- Return type
Iterable
[~_Member]
-
classmethod
load
(s, sources, name, checksum=None)[source]¶ Load an instance of the register class from storage.
- Return type
~_Self
-
member_type
= None¶ The type of members contained by an instance of a register class.
-
property
members
¶ Accessor for the members of a register instance.
- Return type
MutableMapping
[~_MemberName, ~_Member]
-
property
number_of_versions
¶ Number of e-print versions contained within a register instance.
- Return type
-
record
= None¶ The record object on a register instance.
-
record_type
= None¶ The type of the record object on a register instance.
-
-
exception
arxiv.canonical.register.
ConsistencyError
[source]¶ Bases:
Exception
Operation was attempted that would violate consistency of the record.
-
class
arxiv.canonical.register.
IRegisterAPI
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Interface for the canonical register API.
-
class
arxiv.canonical.register.
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.register.
ICanonicalSource
(*args, **kwargs)[source]¶ Bases:
typing_extensions.Protocol
Interface for source services, used to dereference URIs.
-
class
arxiv.canonical.register.
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]
-
-
exception
arxiv.canonical.register.
NoSuchResource
[source]¶ Bases:
Exception
Operation was attempted on a non-existant resource.
-
class
arxiv.canonical.register.
RegisterAPI
(storage, sources, name='all')[source]¶ Bases:
arxiv.canonical.core.IRegisterAPI
The main public API for the register.
-
load_events
(selector)[source]¶ Load all :class:`.Event`s for a day, month, or year.
Returns an
Event
generator that loads event data lazily from the underlying storage, so that in general we are loading only the data that we are actually consuming. Events are generated in order.But be warned! Evaluating the entire generator all at once (e.g. by coercing it to a
list
) may load a considerable amount of data into memory (and use a lot of i/o), especially if events for an entire year are loaded.- Parameters
selector (int, tuple, or
datetime.date
) – Indicates the year (int), month (Tuple[int, int]), or day for which events should be loaded.- Returns
generator – Yields
Event
instances in chronological order.int – An estimate of the number of events that will be generated. Note that the actual number may change (especially for large selections) because the record may be updated while the generator is being consumed.
- Return type
-
-
class
arxiv.canonical.register.
RegisterDay
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
Representation of a day-block of e-prints in the canonical register.
-
domain_type
¶
-
integrity_type
¶
-
member_type
¶ alias of
RegisterEPrint
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterEPrint
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
Representation of an e-print in the canonical register.
Organizes a series of one or more :class:`.RegisterVersion`s.
-
add_event_replace
(s, sources, event)[source]¶ Add an event that generates a replacement version.
- Return type
-
add_event_update
(s, sources, event)[source]¶ Add an event that results in an update to a version.
- Return type
-
add_event_update_metadata
(s, sources, event)[source]¶ Add an event that results in an update to metadata of a version.
- Return type
-
domain_type
¶ alias of
arxiv.canonical.domain.eprint.EPrint
-
integrity_type
¶
-
member_type
¶
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterEPrints
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
Representation of the complete set of e-prints in the register.
-
domain_type
¶
-
integrity_type
¶
-
member_type
¶ alias of
RegisterYear
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterListing
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
add_events
(_, sources, *events)[source]¶ Add events to the terminal listing R.
Overrides the base method since this is a terminal record, not a collection.
- Return type
None
-
domain_type
¶
-
integrity_type
¶
-
classmethod
load
(s, sources, identifier, checksum=None)[source]¶ Load an instance of the register class from storage.
- Return type
~_Self
-
member_type
¶ alias of
builtins.NoneType
-
property
number_of_versions
¶ Number of e-print versions contained within a register instance.
- Return type
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterListings
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
domain_type
¶
-
integrity_type
¶ alias of
arxiv.canonical.integrity.listing.IntegrityListings
-
member_type
¶ alias of
RegisterListingYear
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterListingDay
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
domain_type
¶
-
integrity_type
¶ alias of
arxiv.canonical.integrity.listing.IntegrityListingDay
-
member_type
¶ alias of
RegisterListing
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterListingMonth
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
domain_type
¶
-
integrity_type
¶ alias of
arxiv.canonical.integrity.listing.IntegrityListingMonth
-
member_type
¶ alias of
RegisterListingDay
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterListingYear
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
domain_type
¶
-
integrity_type
¶ alias of
arxiv.canonical.integrity.listing.IntegrityListingYear
-
member_type
¶ alias of
RegisterListingMonth
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterMetadata
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
domain_type
¶
-
integrity_type
¶ alias of
arxiv.canonical.integrity.metadata.IntegrityMetadata
-
member_type
¶ alias of
builtins.NoneType
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterMonth
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
Representation of a month-block in the canonical register.
-
domain_type
¶
-
integrity_type
¶
-
member_type
¶ alias of
RegisterDay
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterVersion
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
-
domain_type
¶
-
integrity_type
¶
-
classmethod
load
(s, sources, identifier, checksum=None)[source]¶ Load an e-print
Version
from s.This method is overridden since it uses a different member mapping struct than higher-level collection types.
- Return type
~_Self
-
member_type
¶
-
property
number_of_versions
¶ Number of e-print versions contained within a register instance.
- Return type
-
record_type
¶
-
-
class
arxiv.canonical.register.
RegisterYear
(name, domain, record, integrity, members=None)[source]¶ Bases:
arxiv.canonical.register.core.Base
Representation of a year-block in the canonical register.
-
domain_type
¶
-
integrity_type
¶
-
member_type
¶ alias of
RegisterMonth
-
record_type
¶
-
Subpackages¶
Submodules¶
- arxiv.canonical.register.api module
- arxiv.canonical.register.core module
- arxiv.canonical.register.eprint module
- arxiv.canonical.register.exceptions module
- arxiv.canonical.register.file module
- arxiv.canonical.register.listing module
- arxiv.canonical.register.metadata module
- arxiv.canonical.register.methods module
- arxiv.canonical.register.util module
- arxiv.canonical.register.version module