datacatalog package¶
Modules¶
application¶
-
class
Application(*args, middlewares=None, **kwargs)[source]¶ Bases:
aiohttp.web_app.ApplicationThe Application.
Todo
Inheritance from
web.Applicationis discouraged by aiohttp. This class, with its initializer, must be replaced by an application factory method that builds an application object fromweb.Application.-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 82¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
config¶
-
hooks¶
-
pm¶
-
pool¶
-
-
_resolve_plugin_path(fq_name)[source]¶ Resolve the path to a plugin (module, class, or instance).
Parameters: fq_name (str) – The fully qualified name of a module, class or instance.
Raises: - ModuleNotFoundError – if the module could not be found
- AttributeError – if the plugin could not be found in the module
config¶
Module that loads the configuration settings for all our services.
-
CONFIG_PATH¶ If set, the configuration is loaded from this path.
Example usage:
from . import config
CONFIG = config.load()
os.chdir(CONFIG['working_directory'])
-
DEFAULT_CONFIG_PATHS¶ Vartype: list[ pathlib.Path]By default, this variable is initialized with:
/etc/dcatd.yml./config.yml
-
class
ConfigDict[source]¶ Bases:
dict-
validate(schema)[source]¶ Validate this config dict using the JSON schema given in
schema.Raises: ConfigError– if schema validation failed
-
-
exception
ConfigError[source]¶ Bases:
ExceptionConfiguration Error
Todo
Documentation: When is this error raised?
-
DEFAULT_CONFIG_PATHS= [PosixPath('/etc/dcatd.yml'), PosixPath('config.yml')] List of locations to look for a configuration file.
-
class
_TemplateWithDefaults(template)[source]¶ Bases:
string.TemplateString template that supports Bash-style default values for interpolation.
Copied from Docker Compose
-
idpattern= '[_a-z][_a-z0-9]*(?::?-[^}]+)?'¶
-
pattern= re.compile('\n \\$(?:\n (?P<escaped>\\$) | # Escape sequence of two delimiters\n (?P<named>[_a-z][_a-z0-9]*(?::?-[^}]+)?) | # delimiter and a Python identifier\n {(?P<braced>[_a-z][_a-, re.IGNORECASE|re.VERBOSE)¶
-
-
_config_path()[source]¶ Determines which path to use for the configuration file.
Raises: FileNotFoundError– if no config file could be found at any location.Return type: Path
-
_interpolate(config)[source]¶ Substitute environment variables.
Recursively find string-type values in the given
config, and try to substitute them with values fromos.environ.Note
If a substituted value is a string containing only digits (i.e.
str.isdigit()is True), then this function will cast it to an integer. It does not try to do any other type conversion.Parameters: config ( dict) – configuration mappingReturn type: dict
-
_load_yaml(path)[source]¶ Read the config file from
path.Raises: yaml.YAMLError– syntax error in YAML.KeyError– Required environment value not found.
Return type:
-
load()[source]¶ Load and validate the configuration.
Return type: ConfigDict
dcat¶
-
class
Date(*args, format=None, pattern=None, **kwargs)[source]¶ Bases:
datacatalog.dcat.String
-
class
Enum(values, *args, allow_empty=None, **kwargs)[source]¶ Bases:
datacatalog.dcat.String-
schema¶
-
-
class
Integer(*args, multipleOf=None, maximum=None, exclusiveMaximum=None, minimum=None, exclusiveMinimum=None, **kwargs)[source]¶ Bases:
datacatalog.dcat.Type-
schema¶
-
-
class
Language(*args, format=None, pattern=None, **kwargs)[source]¶ Bases:
datacatalog.dcat.String
-
class
List(item_type, *args, required=False, default=None, allow_empty=True, unique_items=None, **kwargs)[source]¶ Bases:
datacatalog.dcat.Type-
full_text_search_representation(data)[source]¶ We must check whether the given data is really a list, jsonld may flatten lists.
-
schema¶
-
-
class
Object(*args, **kwargs)[source]¶ Bases:
datacatalog.dcat.Type-
property_names¶
-
schema¶
-
-
class
OneOf(*types, **kwargs)[source]¶ Bases:
datacatalog.dcat.Type-
schema¶
-
validate(data)[source]¶ Validate the data.
Returns: the Type for which validation succeeded. See also OneOf.validate()Return type: Type
-
-
class
PlainTextLine(*args, pattern=None, **kwargs)[source]¶ Bases:
datacatalog.dcat.String
-
class
String(*args, pattern=None, max_length=None, allow_empty=False, **kwargs)[source]¶ Bases:
datacatalog.dcat.Type-
schema¶
-
-
class
Type(*args, title=None, description=None, required=False, default=None, examples=None, format=None, read_only=None, write_only=None, sys_defined=None, **kwargs)[source]¶ Bases:
object-
schema¶
-
validate(data)[source]¶ Validate the data.
Returns: the Type for which validation succeeded. See also OneOf.validate()Return type: Type
-
jwks¶
Helper module to handle JWKS stuff.
This module provides only one method: load(), which may raise a
JWKError.
-
MappingProxyType¶ alias of
builtins.mappingproxy
-
_Key¶ Immutable type for key storage
alias of
datacatalog.jwks.Key
-
_KeySet¶ Immutable type for key sets
alias of
datacatalog.jwks.KeySet
openapi¶
plugin_interfaces¶
-
deinitialize(app)[source]¶ Called when the application shuts down.
Parameters: app – the Applicationobject.Return type: None
-
health_check(app)[source]¶ Health check.
Return type: Optional[str]Returns: If unhealthy, a string describing the problem, otherwise None.Raises: Exception – if that’s easier than returning a string.
-
initialize(app)[source]¶ Called by the plugin-manager when the event loop starts.
If your plugin needs to do some initialization even before the event loop starts, you’ll need to do this in
initialize_sync().Parameters: app – the Applicationobject.Return type: None
-
initialize_sync(app)[source]¶ The first method to be called by the plugin-manager.
If your plugin needs to do some asynchronous initialization, try
initialize()Parameters: app – the Applicationobject.Return type: None
-
mds_canonicalize(data, id=None, direction=<Direction.GET: 0>)[source]¶ Canonicalize the given document according to this schema.
Return type: dictReturns: dict with canonicalized entries
-
mds_full_text_search_representation(data)[source]¶ Full text search representation of the given data.
Return type: str
-
mds_name()[source]¶ The schema this plugin provides.
Return type: strReturns: a string that is safe for use in a URL segment; ie. every string that matches regular expression ^(?:%[a-f0-9]{2}|[-\w:@!$&'()*+,;=.~])*$
-
search_search(app, q, sort_field_get, result_info, facets=None, limit=None, offset=0, filters=None, iso_639_1_code=None)[source]¶ Search.
Parameters: - app – the application
- q (
str) – the query - sort_field_get (
Callable[[dict],str]) – function to get propererty to sort by. - result_info (
Mutablemapping[~KT, ~VT]) – mapping in which all encountered facets in the result set are put - facets (
Optional[Iterable[str]]) – a list of facets to return and count - limit (
Optional[int]) – maximum hits to be returned - offset (
Optional[int]) – offset in resultset - filters (
Optional[Mapping[str,Mapping[str,Union[str,Set[str]]]]]) – mapping of JSON pointer -> value, used to filter on some value. - iso_639_1_code (
Optional[str]) – the language of the query
Return type: Returns: A generator over the search results (id, doc, metadata)
Raises: ValueError if filter syntax is invalid, if the ISO 639-1 code is not recognized, or if the offset is invalid.
-
storage_create(app, docid, doc, searchable_text, iso_639_1_code)[source]¶ Store a new document.
Parameters: - app – the application
- docid (
str) – the ID under which to store this document. May or may not already exist in the data store. - doc (
dict) – the document to store; a “JSON dictionary”. - searchable_text (
str) – this will be indexed for free-text search. - iso_639_1_code (
Optional[str]) – the language of the document.
Return type: Returns: new ETag
Raises: KeyError if the docid already exists.
-
storage_delete(app, docid, etags)[source]¶ Delete document only if it has one of the provided Etags.
Parameters: Raises: ValueError if none of the given etags match the stored etag.
Raises: KeyError if a document with the given id doesn’t exist.
Return type: None
-
storage_extract(app, ptr, distinct=False)[source]¶ Generator to extract values from the stored documents, optionally distinct.
Used to, for example, get a list of all tags or ids in the system. Or to get all documents stored in the system.
Parameters: Raises: ValueError if filter syntax is invalid.
Return type:
-
storage_retrieve(app, docid, etags)[source]¶ Get document and corresponsing etag by id.
Parameters: Return type: Returns: A tuple. The first element is either the document or None if the document’s Etag corresponds to one of the given etags. The second element is the current etag.
Raises: KeyError – if not found
-
storage_update(app, docid, doc, searchable_text, etags, iso_639_1_code)[source]¶ Update the document with the given ID only if it has one of the provided Etags.
Parameters: - app – the application
- docid (
str) – the ID under which to store this document. May or may not already exist in the data store. - doc (
dict) – the document to store; a “JSON dictionary”. - searchable_text (
str) – this will be indexed for free-text search. - etags (
Set[str]) – one or more Etags. - iso_639_1_code (
Optional[str]) – the language of the document.
Return type: Returns: new ETag
Raises: ValueError if none of the given etags match the stored etag.
Raises: KeyError if the docid doesn’t exist.