schema_salad.python_codegen_support
Template code used by python_codegen.py.
Attributes
Classes
Mark classes than have a save() and fromDoc() function. |
Functions
|
Load field. |
|
Take a type of value, and extracts the value as a string. |
|
Normalize type names to schema-salad types. |
|
Parse error messages from several loaders into one error message. |
|
|
|
Save and set $namespaces, $schemas, $base and any other metadata fields at the top level. |
|
|
|
Transform a file path into a URL with file scheme. |
|
Expand short forms into full URLs using the given namespace dictionary. |
|
Convert any URI to a relative one, obeying the scoping rules. |
|
Compute the shortname of a fully qualified identifier. |
Module Contents
- schema_salad.python_codegen_support.IdxType
- 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:
fetcher (Optional[schema_salad.fetcher.Fetcher])
namespaces (Optional[dict[str, str]])
schemas (Optional[list[str]])
fileuri (Optional[str])
copyfrom (Optional[LoadingOptions])
original_doc (Optional[Any])
addl_metadata (Optional[dict[str, str]])
baseuri (Optional[str])
idx (Optional[IdxType])
imports (Optional[list[str]])
includes (Optional[list[str]])
no_link_check (Optional[bool])
container (Optional[str])
- idx: IdxType
- fileuri: str | None
- baseuri: str
- namespaces: collections.abc.MutableMapping[str, str]
- schemas: collections.abc.MutableSequence[str]
- original_doc: Any | None
- addl_metadata: collections.abc.MutableMapping[str, Any]
- fetcher: schema_salad.fetcher.Fetcher
- vocab: dict[str, str]
- rvocab: dict[str, str]
- cache: schema_salad.utils.CacheType
- imports: list[str]
- includes: list[str]
- no_link_check: bool | None
- container: 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
Bases:
digraph inheritance09618532e3 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "ABC" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Helper class that provides a standard way to create an ABC using"]; "Saveable" [URL="#schema_salad.python_codegen_support.Saveable",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Mark classes than have a save() and fromDoc() function."]; "ABC" -> "Saveable" [arrowsize=0.5,style="setlinewidth(0.5)"]; }abc.ABC
Mark classes than have a save() and fromDoc() function.
- classmethod fromDoc(_doc, baseuri, loadingOptions, docRoot=None)
- Abstractmethod:
- Parameters:
_doc (Any)
baseuri (str)
loadingOptions (LoadingOptions)
docRoot (Optional[str])
- Return type:
Construct this object from the result of yaml.load().
- abstract save(top=False, base_url='', relative_uris=True)
Convert this object to a JSON/YAML friendly dictionary.
- Parameters:
top (bool)
base_url (str)
relative_uris (bool)
- Return type:
dict[str, Any]
- schema_salad.python_codegen_support.load_field(val, fieldtype, baseuri, loadingOptions, lc=None)
Load field.
- Parameters:
val (Union[str, dict[str, str]])
fieldtype (_Loader)
baseuri (str)
loadingOptions (LoadingOptions)
lc (Optional[list[Any]])
- Return type:
Any
- schema_salad.python_codegen_support.save_type
- 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:
val (Any)
valLoadingOpts (LoadingOptions)
top (bool)
base_url (str)
relative_uris (bool)
- 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:
url (str)
base_url (str)
loadingOptions (LoadingOptions)
scoped_id (bool)
vocab_term (bool)
scoped_ref (Optional[int])
- 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:
path (str)
split_frag (bool)
- Return type:
str
- schema_salad.python_codegen_support.prefix_url(url, namespaces)
Expand short forms into full URLs using the given namespace dictionary.
- Parameters:
url (str)
namespaces (dict[str, str])
- 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 (Optional[int])
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