hermes.commands.marketplace
===========================

.. py:module:: hermes.commands.marketplace

.. autoapi-nested-parse::

   Basic CLI to list plugins from the Hermes marketplace.



Attributes
----------

.. autoapisummary::

   hermes.commands.marketplace.MARKETPLACE_URL
   hermes.commands.marketplace.schema_org_hermes


Classes
-------

.. autoapisummary::

   hermes.commands.marketplace.SchemaOrgModel
   hermes.commands.marketplace.SchemaOrgOrganization
   hermes.commands.marketplace.SchemaOrgSoftwareApplication
   hermes.commands.marketplace.PluginMarketPlaceParser
   hermes.commands.marketplace.PluginInfo


Functions
---------

.. autoapisummary::

   hermes.commands.marketplace._doi_is_version_of_concept_doi
   hermes.commands.marketplace._is_hermes_reference
   hermes.commands.marketplace._sort_plugins_by_step
   hermes.commands.marketplace._plugin_loc
   hermes.commands.marketplace.main
   hermes.commands.marketplace.get_plugin_infos


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

.. py:data:: MARKETPLACE_URL
   :value: 'https://hermes.software-metadata.pub/marketplace'


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

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


   Basic model for Schema.org JSON-LD validation and serialization.


   .. py:attribute:: model_config

      Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict].


   .. py:attribute:: context_
      :type:  str
      :value: None



   .. py:attribute:: type_
      :type:  str
      :value: None



   .. py:attribute:: id_
      :type:  Optional[str]
      :value: None



   .. py:method:: model_dump_jsonld()


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

   Bases: :py:obj:`SchemaOrgModel`


   Validation and serialization of ``schema:Organization``.

   This model does not incorporate all possible fields and is meant to be used merely
   for the purposes of the Hermes marketplace.


   .. py:attribute:: type_
      :type:  str
      :value: None



   .. py:attribute:: name
      :type:  str


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

   Bases: :py:obj:`SchemaOrgModel`


   Validation and serialization of ``schema:SoftwareApplication``.

   This model does not incorporate all possible fields and is meant to be used merely
   for the purposes of the Hermes marketplace.


   .. py:attribute:: type_
      :type:  str
      :value: None



   .. py:attribute:: name
      :type:  str


   .. py:attribute:: url
      :type:  Optional[str]
      :value: None



   .. py:attribute:: install_url
      :type:  Optional[str]
      :value: None



   .. py:attribute:: abstract
      :type:  Optional[str]
      :value: None



   .. py:attribute:: author
      :type:  Optional[SchemaOrgOrganization]
      :value: None



   .. py:attribute:: is_part_of
      :type:  Optional[SchemaOrgSoftwareApplication]
      :value: None



   .. py:attribute:: keywords
      :type:  List[str]
      :value: None



.. py:data:: schema_org_hermes

.. py:class:: PluginMarketPlaceParser(*args, **kwargs)

   Bases: :py:obj:`html.parser.HTMLParser`


   Parser for the JSON-LD Schema.org markup used in the marketplace.


   .. py:attribute:: is_json_ld
      :type:  bool
      :value: False



   .. py:attribute:: plugins
      :type:  List[SchemaOrgSoftwareApplication]
      :value: []



   .. py:method:: handle_starttag(tag, attrs)


   .. py:method:: handle_endtag(tag)


   .. py:method:: handle_data(data)


   .. py:method:: parse_plugins_from_url(url: str = MARKETPLACE_URL, user_agent: str = hermes_user_agent)


.. py:function:: _doi_is_version_of_concept_doi(doi: str, concept_doi: str) -> bool

   Check whether ``doi`` is a version of ``concept_doi``.

   The check is performed by requesting ``doi`` from the DataCite API and checking
   whether its related identifier of type ``IsVersionOf`` points to ``concept_doi``.
   This is the case if ``conecpt_doi`` is the concept DOI of ``doi``.


.. py:function:: _is_hermes_reference(reference: Optional[SchemaOrgModel])

   Figure out whether ``reference`` refers to HERMES.


.. py:function:: _sort_plugins_by_step(plugins: list[SchemaOrgSoftwareApplication]) -> dict[str, list[SchemaOrgSoftwareApplication]]

.. py:function:: _plugin_loc(_plugin: SchemaOrgSoftwareApplication) -> str

.. py:function:: main()

.. py:class:: PluginInfo

   This class contains all the information about a plugin which are needed for the init-Command.


   .. py:attribute:: name
      :type:  str
      :value: ''



   .. py:attribute:: location
      :type:  str
      :value: ''



   .. py:attribute:: step
      :type:  str
      :value: ''



   .. py:attribute:: builtin
      :type:  bool
      :value: True



   .. py:attribute:: install_url
      :type:  str
      :value: ''



   .. py:attribute:: abstract
      :type:  str
      :value: ''



   .. py:method:: __str__()


   .. py:method:: get_pip_install_command() -> str

      Returns the pip install command which can be used to install the plugin.
      Tries to extract the project name from the install_url (PyPI-URL) if possible.
      Otherwise, it tries to use the location (Git-Project-URL) for the pip install command.



   .. py:method:: is_valid() -> bool

      Returns True if the plugin can be installed. Maybe we'll check the actual repository here later
      to make sure that other things are valid too.



.. py:function:: get_plugin_infos() -> list[PluginInfo]

   Returns a List of PluginInfos which are meant to be used by the init-command.


