hermes.commands.harvest.base
============================

.. py:module:: hermes.commands.harvest.base


Classes
-------

.. autoapisummary::

   hermes.commands.harvest.base.HermesHarvestPlugin
   hermes.commands.harvest.base.HarvestSettings
   hermes.commands.harvest.base.HermesHarvestCommand


Functions
---------

.. autoapisummary::

   hermes.commands.harvest.base.remove_harvest_plugin_from_prov_doc


Module Contents
---------------

.. py:class:: HermesHarvestPlugin

   Bases: :py:obj:`hermes.commands.base.HermesPlugin`


   Base plugin that does harvesting.

   .. attribute:: operations

      The information recorded on the
      load operations executed by the plugin.

      :type: list[tuple[dict[str, str], dict[str, str], dict[str, str]]]

   TODO: describe the harvesting process and how this is mapped to this plugin.


   .. py:method:: __call__(command: HermesHarvestCommand) -> hermes.model.SoftwareMetadata

      Execute the hermes harvest plugin `self`.

      :param command: The command being executed.
      :type command: HermesHarvestCommand

      :returns: The harvested metadata.
      :rtype: SoftwareMetadata



   .. py:method:: load(func: Callable, source: Any, *args: Optional[Any], encoding: Optional[str] = 'utf-8', **kwargs: Optional[Any]) -> Any

      Load some data from some source using some function so that the calls provenance information is recorded.

      `func(source, *args, **kwargs)` will be executed.

      :param func: The function used for loading the requested source.
      :type func: Callable
      :param source: The source the data is to be loaded from.
      :type source: Any
      :param args: Additional positional arguments for the load.
      :type args: Any | None
      :param encoding: Encoding for loaded file, utf-8 is default.
      :type encoding: str
      :param kwargs: Additional keyword arguments for the load.
      :type kwargs: Any | None

      :returns: The result of the load operation.
      :rtype: Any



.. py:class:: HarvestSettings(/, **data: Any)

   Bases: :py:obj:`pydantic.BaseModel`


   Generic harvesting settings.

   .. attribute:: sources

      (class attribute) A list of plugins to be executed.

      :type: list[str]


.. py:function:: remove_harvest_plugin_from_prov_doc(prov_doc: hermes.model.provenance.ld_prov.ld_prov_list, plugin: str) -> None

   Removes information on the specified harvest plugin from the given provenance document.

   :param prov_doc: The provenance document the plugins information is to be removed from.
   :type prov_doc: ld_prov_list
   :param plugin: The name of the plugin of which the information is to be removed.
   :type plugin: str

   :rtype: None


.. py:class:: HermesHarvestCommand(parser: argparse.ArgumentParser)

   Bases: :py:obj:`hermes.commands.base.HermesCommand`


   Harvest metadata from configured sources.

   .. attribute:: args

      The namespace that was returned by the command line parser when reading the arguments.

      :type: Namespace

   .. attribute:: command_name

      (class attribute) The name of the command

      :type: str

   .. attribute:: settings_class

      (class attribute) The settings class for general harvest settings.

      :type: type


   .. py:method:: __call__(args: argparse.Namespace) -> None

      Execute the hermes command `self`.

      :param args: The namespace that was returned by the command line parser when reading the arguments.
      :type args: Namespace

      :rtype: None

      :raises MisconfigurationError: If no plugin is configured to be run.
      :raises HermesPluginRunError: If all plugin runs failed.



   .. py:method:: init_provenance_document() -> hermes.model.provenance.ld_prov.ld_prov_list
      :classmethod:


      Loads or creates a provenance document.

      :returns: The loaded or created provenance document.
      :rtype: ld_prov_list



