Executors¶
module: rspub.core.executors
Events and base classes for execution
-
class
rspub.core.executors.
ExecutorEvent
[source]¶ Bases:
enum.Enum
Events fired by Executors
There are information events (
inform
) and confirmation events (confirm
). If anObserver
overrides the methodconfirm()
and returnsFalse
on aconfirm
event, anObserverInterruptException
is raised.All events are broadcast in the format:
[inform][confirm](source, event, **kwargs)
where
source
is the calling instance,event
is the relevant event and**kwargs
hold relevant information about the event.-
rejected_file
= 1¶ 1
inform
File rejected by resource gate
-
start_file_search
= 2¶ 2
inform
File search was started
-
created_resource
= 3¶ 3
inform
The metadata for a resource was created
-
completed_document
= 10¶ 10
inform
A sitemap document was completed
-
found_changes
= 20¶ 20
inform
Resources that changed were found
-
execution_start
= 30¶ 30
inform
Execution of resource synchronization started
-
execution_end
= 31¶ 31
inform
Execution of resource synchronization did end
-
clear_metadata_directory
= 100¶ 100
confirm
Files 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:
object
Holds metadata about sitemaps
-
__init__
(resource_count=0, ordinal=0, uri=None, path=None, capability_name=None, document_saved=False)[source]¶ Initialization
Parameters: - 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.Observable
Abstract base class for ResourceSync execution
There are 6
build steps
that 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]¶ Initialization
If no
RsParameters
were given will construct newRsParameters
from configuration found undercurrent_configuration_name()
.Parameters: rs_parameters – RsParameters
for execution
-
execute
(filenames: <built-in function iter>)[source]¶ build step 0
Publish ResourceSync documents
Publish ResourceSync documents under conditions of current
RsParameters
.Parameters: filenames – iter of filenames and/or directories to scan Returns: list of SitemapData
of generated sitemaps
-
prepare_metadata_dir
()[source]¶ build step 1
Does nothing
Subclasses 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 2
Raises NotImplementedError
Subclasses must walk resources found in
filenames
and, if appropriate, generate sitemaps and produce sitemap data.Parameters: filenames – list of filenames and/or directories to scan Returns: list of SitemapData
of generated sitemaps
-
post_process_documents
(sitemap_data_iter: <built-in function iter>)[source]¶ build step 3
Does nothing
Subclasses that want to post proces the documents in metadata directory may override.
Parameters: sitemap_data_iter – iter over SitemapData
of sitemaps generated in build step 2
-
create_index
(sitemap_data_iter: <built-in function iter>)[source]¶ build step 4
Raises NotImplementedError
Subclasses must create sitemap indexes if appropriate.
Parameters: sitemap_data_iter – iter over SitemapData
of sitemaps generated in build step 2
-
create_capabilitylist
() → rspub.core.executors.SitemapData[source]¶ build step 5
Create a new capabilitylist over sitemaps found in metadata directory
Returns: SitemapData
over the newly created capabilitylist
-
update_resource_sync
(capabilitylist_data)[source]¶ build step 6
Update description with newly created capabilitylist
Parameters: capabilitylist_data – SitemapData
over the newly created capabilitylistReturns: SitemapData
over updated description
-