cata_log_hub.database package
- class cata_log_hub.database.Catalog[source]
Bases:
ModelBase,TimestampMixinORM model for a catalog.
- as_pdf()[source]
Compress the catalog to a pdf file.
- Return type:
- Returns:
The pdf file bytes.
- as_epub()[source]
Convert the catalog to a epub file.
- Return type:
- Returns:
The epub file bytes.
- classmethod cleanup(db_session, deadline)[source]
Cleanup catalogs created before a deadline.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class cata_log_hub.database.ModelBase[source]
Bases:
DeclarativeBaseBase for all ORM models.
- metadata: ClassVar[MetaData] = MetaData()
Refers to the
_schema.MetaDatacollection that will be used for new_schema.Tableobjects.See also
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class cata_log_hub.database.Page[source]
Bases:
ModelBase,TimestampMixinORM model for a catalog page.
- validate_nonnegative_number(key, number)[source]
Ensure number is nonnegative.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class cata_log_hub.database.PageFile[source]
Bases:
ModelBase,TimestampMixinORM model for a catalog page file.
- validate_nonnegative_number(key, value)[source]
Ensure size values are positive.
- property name: str
The name of the stored file.
- classmethod get_or_create(db_session, page_bytes)[source]
Get or create a pagefile.
- classmethod cleanup(db_session)[source]
Cleanup unused page files.
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class cata_log_hub.database.Provider[source]
Bases:
ModelBase,TimestampMixinORM model for a catalog provider.
- status: Mapped[StatusEnum]
- get_provider_class()[source]
Get the class for this provider.
- Return type:
- Returns:
The provider class.
- Raises:
cata_log_hub.exceptions.ProviderUnknownClassWarning – If there is no class for this provider’s class-uid.
- get_provider_instance()[source]
Get a class instance for this provider.
- Return type:
- Returns:
The provider instance.
- Raises:
cata_log_hub.exceptions.ProviderUnknownClassWarning – If there is no class for this provider’s class-uid.
- fetch_catalog(db_session)[source]
Fetch this provider’s catalog and save it to storage and db.
- Raises:
cata_log_hub.exceptions.NetworkError – Reraised
- Return type:
- Parameters:
db_session (Session)
- __init__(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- cata_log_hub.database.get_db_session()[source]
Shortcut to get a new database session.