schema_salad.python_codegen_support

Template code used by python_codegen.py.

Attributes

IdxType

S

save_type

Classes

LoadingOptions

Saveable

Mark classes than have a save() and fromDoc() function.

Functions

load_field(val, fieldtype, baseuri, loadingOptions[, lc])

Load field.

extract_type(val_type)

Take a type of value, and extracts the value as a string.

convert_typing(val_type)

Normalize type names to schema-salad types.

parse_errors(error_message)

Parse error messages from several loaders into one error message.

save(val[, top, base_url, relative_uris])

save_with_metadata(val, valLoadingOpts[, top, ...])

Save and set $namespaces, $schemas, $base and any other metadata fields at the top level.

expand_url(url, base_url, loadingOptions[, scoped_id, ...])

file_uri(path[, split_frag])

Transform a file path into a URL with file scheme.

prefix_url(url, namespaces)

Expand short forms into full URLs using the given namespace dictionary.

save_relative_uri(uri, base_url, scoped_id, ref_scope, ...)

Convert any URI to a relative one, obeying the scoping rules.

shortname(inputid)

Compute the shortname of a fully qualified identifier.

Module Contents

type schema_salad.python_codegen_support.IdxType = MutableMapping[str, tuple[Any, 'LoadingOptions']]
schema_salad.python_codegen_support.S
class schema_salad.python_codegen_support.LoadingOptions(fetcher=None, namespaces=None, schemas=None, fileuri=None, copyfrom=None, original_doc=None, addl_metadata=None, baseuri=None, idx=None, imports=None, includes=None, no_link_check=None, container=None)
Parameters:
idx: Final[IdxType]
fileuri: Final[str | None]
baseuri: Final[str]
namespaces: Final[collections.abc.MutableMapping[str, str]]
schemas: Final[collections.abc.MutableSequence[str]]
original_doc: Final[Any | None]
addl_metadata: Final[collections.abc.MutableMapping[str, Any]]
fetcher: Final[schema_salad.fetcher.Fetcher]
vocab: Final[dict[str, str]]
rvocab: Final[dict[str, str]]
cache: Final[schema_salad.utils.CacheType]
imports: Final[list[str]]
includes: Final[list[str]]
container: Final[str | None]
property graph: rdflib.Graph

Generate a merged rdflib.Graph from all entries in self.schemas.

Return type:

rdflib.Graph

class schema_salad.python_codegen_support.Saveable

Mark classes than have a save() and fromDoc() function.

classmethod fromDoc(_doc, baseuri, loadingOptions, docRoot=None)
Abstractmethod:

Parameters:
Return type:

Self

Construct this object from the result of yaml.load().

abstractmethod save(top=False, base_url='', relative_uris=True)

Convert this object to a JSON/YAML friendly dictionary.

Parameters:
Return type:

dict[str, Any]

schema_salad.python_codegen_support.load_field(val, fieldtype, baseuri, loadingOptions, lc=None)

Load field.

Parameters:
  • val (Any | None)

  • fieldtype (_Loader)

  • baseuri (str)

  • loadingOptions (LoadingOptions)

  • lc (Any | None)

Return type:

Any

type schema_salad.python_codegen_support.save_type = None | MutableMapping[str, Any] | MutableSequence[Any] | int | float | bool | str
schema_salad.python_codegen_support.extract_type(val_type)

Take a type of value, and extracts the value as a string.

Parameters:

val_type (type[Any])

Return type:

str

schema_salad.python_codegen_support.convert_typing(val_type)

Normalize type names to schema-salad types.

Parameters:

val_type (str)

Return type:

str

schema_salad.python_codegen_support.parse_errors(error_message)

Parse error messages from several loaders into one error message.

Parameters:

error_message (str)

Return type:

tuple[str, str, str]

schema_salad.python_codegen_support.save(val, top=True, base_url='', relative_uris=True)
Parameters:
  • val (Any)

  • top (bool)

  • base_url (str)

  • relative_uris (bool)

Return type:

save_type

schema_salad.python_codegen_support.save_with_metadata(val, valLoadingOpts, top=True, base_url='', relative_uris=True)

Save and set $namespaces, $schemas, $base and any other metadata fields at the top level.

Parameters:
Return type:

save_type

schema_salad.python_codegen_support.expand_url(url, base_url, loadingOptions, scoped_id=False, vocab_term=False, scoped_ref=None)
Parameters:
Return type:

str

schema_salad.python_codegen_support.file_uri(path, split_frag=False)

Transform a file path into a URL with file scheme.

Parameters:
Return type:

str

schema_salad.python_codegen_support.prefix_url(url, namespaces)

Expand short forms into full URLs using the given namespace dictionary.

Parameters:
Return type:

str

schema_salad.python_codegen_support.save_relative_uri(uri, base_url, scoped_id, ref_scope, relative_uris)

Convert any URI to a relative one, obeying the scoping rules.

Parameters:
  • uri (Any)

  • base_url (str)

  • scoped_id (bool)

  • ref_scope (int | None)

  • relative_uris (bool)

Return type:

Any

schema_salad.python_codegen_support.shortname(inputid)

Compute the shortname of a fully qualified identifier.

See https://w3id.org/cwl/v1.2/SchemaSalad.html#Short_names.

Parameters:

inputid (str)

Return type:

str