Executors¶
module: rspub.core.executors
Events and base classes for execution
-
class
rspub.core.executors.ExecutorEvent[source]¶ Bases:
enum.EnumEvents fired by ExecutorsThere are information events (
inform) and confirmation events (confirm). If anObserveroverrides the methodconfirm()and returnsFalseon aconfirmevent, anObserverInterruptExceptionis raised.All events are broadcast in the format:
[inform][confirm](source, event, **kwargs)
where
sourceis the calling instance,eventis the relevant event and**kwargshold relevant information about the event.-
rejected_file= 1¶ 1informFile rejected by resource gate
-
start_file_search= 2¶ 2informFile search was started
-
created_resource= 3¶ 3informThe metadata for a resource was created
-
completed_document= 10¶ 10informA sitemap document was completed
-
found_changes= 20¶ 20informResources that changed were found
-
execution_start= 30¶ 30informExecution of resource synchronization started
-
execution_end= 31¶ 31informExecution of resource synchronization did end
-
clear_metadata_directory= 100¶ 100confirmFiles in metadata directory will be erased
-
-
class
rspub.core.executors.SitemapData(resource_count=0, ordinal=0, uri=None, path=None, capability_name=None, document_saved=False)[source]¶ Bases:
objectHolds metadata about sitemaps-
__init__(resource_count=0, ordinal=0, uri=None, path=None, capability_name=None, document_saved=False)[source]¶ InitializationParameters: - resource_count (int) – the amount of records in the sitemap
- ordinal (int) – the ordinal number as reflected in the sitemap filename and url
- uri (str) – the url of the sitemap
- path (str) – the local path of the sitemap
- capability_name (str) – the capability of the sitemap
- document_saved (bool) – True if the sitemap was saved to disk, False otherwise
-
-
class
rspub.core.executors.Executor(rs_parameters: rspub.core.rs_paras.RsParameters = None)[source]¶ Bases:
rspub.util.observe.ObservableAbstract base class for ResourceSync executionThere are 6
build stepsthat concrete subclasses may override (or 7 if they want to completely take over the execution). Two steps are mandatory for subclasses to implement:generate_rs_documents()andcreate_index(). Stepscreate_capabilitylist()andupdate_resource_sync()are not abstract - they can safely be done by thisExecutor.-
__init__(rs_parameters: rspub.core.rs_paras.RsParameters = None)[source]¶ InitializationIf no
RsParameterswere given will construct newRsParametersfrom configuration found undercurrent_configuration_name().Parameters: rs_parameters – RsParametersfor execution
-
execute(filenames: <built-in function iter>)[source]¶ build step 0Publish ResourceSync documentsPublish ResourceSync documents under conditions of current
RsParameters.Parameters: filenames – iter of filenames and/or directories to scan Returns: list of SitemapDataof generated sitemaps
-
prepare_metadata_dir()[source]¶ build step 1Does nothingSubclasses that want to prepare metadata directory before generating new documents may override.
-
generate_rs_documents(filenames: <built-in function iter>) → [<class 'rspub.core.executors.SitemapData'>][source]¶ build step 2Raises NotImplementedErrorSubclasses must walk resources found in
filenamesand, if appropriate, generate sitemaps and produce sitemap data.Parameters: filenames – list of filenames and/or directories to scan Returns: list of SitemapDataof generated sitemaps
-
post_process_documents(sitemap_data_iter: <built-in function iter>)[source]¶ build step 3Does nothingSubclasses that want to post proces the documents in metadata directory may override.
Parameters: sitemap_data_iter – iter over SitemapDataof sitemaps generated in build step 2
-
create_index(sitemap_data_iter: <built-in function iter>)[source]¶ build step 4Raises NotImplementedErrorSubclasses must create sitemap indexes if appropriate.
Parameters: sitemap_data_iter – iter over SitemapDataof sitemaps generated in build step 2
-
create_capabilitylist() → rspub.core.executors.SitemapData[source]¶ build step 5Create a new capabilitylist over sitemaps found in metadata directoryReturns: SitemapDataover the newly created capabilitylist
-
update_resource_sync(capabilitylist_data)[source]¶ build step 6Update description with newly created capabilitylistParameters: capabilitylist_data – SitemapDataover the newly created capabilitylistReturns: SitemapDataover updated description
-