Skip to content

Commit

Permalink
SchemaOrgSoftware{Publication → Application}
Browse files Browse the repository at this point in the history
Parapraxis :-)
  • Loading branch information
zyzzyxdonta committed Dec 19, 2024
1 parent 27bfe15 commit dfbb4c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/source/_ext/plugin_markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from hermes.commands.marketplace import (
SchemaOrgOrganization,
SchemaOrgSoftwarePublication,
SchemaOrgSoftwareApplication,
schema_org_hermes,
)

Expand Down Expand Up @@ -44,7 +44,7 @@ def keywordify(text: str) -> str:
return re.sub(r"[^a-z]", "-", text)


def plugin_to_schema_org(plugin: Dict[str, Any]) -> SchemaOrgSoftwarePublication:
def plugin_to_schema_org(plugin: Dict[str, Any]) -> SchemaOrgSoftwareApplication:
"""Convert plugin metadata from the used JSON format to Schema.org.
The ``plugin`` is transformed into a ``schema:SoftwareApplication``. For most
Expand All @@ -63,7 +63,7 @@ def plugin_to_schema_org(plugin: Dict[str, Any]) -> SchemaOrgSoftwarePublication
harvested_files = plugin.get("harvested_files", [])
keywords += [f"hermes-harvest-{keywordify(file)}" for file in harvested_files]

return SchemaOrgSoftwarePublication(
return SchemaOrgSoftwareApplication(
name=plugin.get("name"),
url=plugin.get("repository_url"),
install_url=plugin.get("pypi_url"),
Expand Down
10 changes: 5 additions & 5 deletions src/hermes/commands/marketplace.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SchemaOrgOrganization(SchemaOrgModel):
name: str


class SchemaOrgSoftwarePublication(SchemaOrgModel):
class SchemaOrgSoftwareApplication(SchemaOrgModel):
"""Validation and serialization of ``schema:SoftwarePublication``.
This model does not incorporate all possible fields and is meant to be used merely
Expand All @@ -60,11 +60,11 @@ class SchemaOrgSoftwarePublication(SchemaOrgModel):
install_url: Optional[str] = None
abstract: Optional[str] = None
author: Optional[SchemaOrgOrganization] = None
is_part_of: Optional["SchemaOrgSoftwarePublication"] = None
is_part_of: Optional["SchemaOrgSoftwareApplication"] = None
keywords: List["str"] = None


schema_org_hermes = SchemaOrgSoftwarePublication(id_=hermes_doi, name="hermes")
schema_org_hermes = SchemaOrgSoftwareApplication(id_=hermes_doi, name="hermes")


class PluginMarketPlaceParser(HTMLParser):
Expand All @@ -73,7 +73,7 @@ class PluginMarketPlaceParser(HTMLParser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.is_json_ld: bool = False
self.plugins: List[SchemaOrgSoftwarePublication] = []
self.plugins: List[SchemaOrgSoftwareApplication] = []

def handle_starttag(self, tag, attrs):
if tag == "script" and ("type", "application/ld+json") in attrs:
Expand All @@ -84,7 +84,7 @@ def handle_endtag(self, tag):

def handle_data(self, data):
if self.is_json_ld:
plugin = SchemaOrgSoftwarePublication.model_validate_json(data)
plugin = SchemaOrgSoftwareApplication.model_validate_json(data)
self.plugins.append(plugin)


Expand Down

0 comments on commit dfbb4c2

Please sign in to comment.