owmeta_core.datasource module¶
- exception owmeta_core.datasource.ExtraSourceFound[source]¶
Bases:
ExceptionRaised by
transformwhen more than one source is found in the current context
- exception owmeta_core.datasource.NoSourceFound[source]¶
Bases:
ExceptionRaised by
transformwhen a source cannot be found in the current context
- exception owmeta_core.datasource.NoTranslatorFound[source]¶
Bases:
ExceptionRaised by
transformwhen a translator cannot be found in the current context
- class owmeta_core.datasource.BaseDataTranslator(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataTransformerInput type(s):
DataSourceOutput type(s):
DataSource- make_transformation(sources=())[source]¶
Just calls
make_translationand returns its result.
- make_translation(sources=())[source]¶
It’s intended that implementations of
BaseDataTranslatorwill override this method to make customTranslationsaccording with how different arguments totranslateare (or are not) distinguished.The actual properties of a
Translationsubclass must be assigned within thetranslatemethod- Parameters
- sources
tuple The sources that go into the translation. Sub-classes may choose to pass these to their superclass’ make_translation method or not.
- sources
- Returns
adescriptionofthetranslation
- translate(*args, **kwargs)[source]¶
Notionally, this method takes one or more data sources, and translates them into some other data source that captures essentially the same information, but, possibly, in a different format. Additional sources can be passed in as well for auxiliary information which are not “translated” in their entirety into the output data source. Such auxiliarry data sources should be distinguished from the primary ones in the translation
- Parameters
- *args
Input data sources
- **kwargs
Named input data sources
- Returns
theoutputdatasource
- class owmeta_core.datasource.DataObjectContextDataSource(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataSource- Input source
ObjectProperty Attribute:
sourceThe data source that was translated into this one
- Transformation
ObjectProperty Attribute:
transformationInformation about the transformation process that created this object
- Translation
ObjectProperty Attribute:
translationInformation about the translation process that created this object
- Description
DatatypeProperty Attribute:
descriptionFree-text describing the data source
- Input source
- class owmeta_core.datasource.DataSource(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectA source for data that can get translated into owmeta_core objects.
The value for any field can be passed to
__init__by name. Additionally, if the sub-class definition of a DataSource assigns a value for that field like:class A(DataSource): some_field = 3
that value will be used over the default value for the field, but not over any value provided to
__init__.- after_transform()[source]¶
Called after
Transformer.transform.This method should handle any of the things that should happen for an output data source after
Transformer.transform(orTranslator.translate). This can include things like flushing output to files, closing file handles, and writing triples in a Context.NOTE: Be sure to call this method via super() in sub-classes
- identifier_augment()[source]¶
It doesn’t make much sense to have translation and transformation set, so we just take the first of them
- description¶
“Description”, a
DatatypeProperty: Free-text describing the data source
- source¶
“Input source”, a
ObjectProperty: The data source that was translated into this one
- transformation¶
“Transformation”, a
ObjectProperty: Information about the transformation process that created this object
- translation¶
“Translation”, a
ObjectProperty: Information about the translation process that created this object
- class owmeta_core.datasource.DataSourceType(name, typ, dct)[source]¶
Bases:
ContextMappedClassA type for DataSources
Sets up the graph with things needed for MappedClasses
- class owmeta_core.datasource.DataTransformer(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectTransforms one or more
DataSourcesto one or more otherDataSources- Attributes
input_typetypeortupleoftypeA source for data that can get translated into owmeta_core objects.
output_typetypeortupleoftypeA source for data that can get translated into owmeta_core objects.
transformation_typetypeRecord of the how a
DataSourcewas produced and the sources of the transformation that produced it.- output_key
str The “key” for outputs from this transformer (see
IdentifierMixin). Normally only defined during execution of __call__- output_identifier
str The identifier for outputs from this transformer. Normally only defined during execution of __call__
- input_type¶
alias of
DataSource
- output_type¶
alias of
DataSource
- transformation_type¶
alias of
Transformation
- after_transform()[source]¶
Called after
transformruns in__call__and after the resultDataSource.after_transformis called.
- make_new_output(sources, *args, **kwargs)[source]¶
Make a new output
DataSource. Typically called withintransform.
- make_transformation(sources=())[source]¶
It’s intended that implementations of
DataTransformerwill override this method to make customTransformationsaccording with how different arguments totransformare (or are not) distinguished.The actual properties of a
Transformationsubclass must be assigned within thetransformmethod
- transform(*args, **kwargs)[source]¶
Notionally, this method takes a data source, which is transformed into some other data source. There doesn’t necessarily need to be an input data source.
- Parameters
- *args
Input data sources
- **kwargs
Named input data sources
- Returns
theoutputdatasource
- transform_with(translator_type, *sources, output_key=None, output_identifier=None, **named_sources)[source]¶
Transform with the given
DataTransformerand sources.This should be used in a
transformimplementation to compose multiple transformations. An instance of the transformer will be created and contextualized with the this transformer’s context unless the given transformer already has a context.
- class owmeta_core.datasource.DataTranslator(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
BaseDataTranslatorA specialization with the
GenericTranslationtranslation type that adds sources for the translation automatically when a new output is made- translation_type¶
alias of
GenericTranslation
- class owmeta_core.datasource.GenericTranslation(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
TranslationA generic translation that just has sources in any order
- class owmeta_core.datasource.OneOrMore(source_type)[source]¶
Bases:
objectWrapper for
DataTransformerinputDataSourcetypes indicating that one or more of the wrapped type must be provided to the translator
- class owmeta_core.datasource.PersonDataTranslator(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
BaseDataTranslatorA person who was responsible for carrying out the translation of a data source manually
- property person¶
A person responsible for carrying out the translation.
- class owmeta_core.datasource.Transformation(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
DataObjectRecord of the how a
DataSourcewas produced and the sources of the transformation that produced it. Unlike the ‘source’ field attached to DataSources, the Translation may distinguish different kinds of input source to a transformation.
- class owmeta_core.datasource.Translation(*args, no_type_decl=False, **kwargs)[source]¶
Bases:
TransformationA transformation where, notionally, the general character of the input is preserved.
In contrast to just a transformation, a translation wouldn’t just pick out, say, one record within an input source containing several, but would have an output source with o
- owmeta_core.datasource.transform(transformer, output_key=None, output_identifier=None, data_sources=(), named_data_sources=None)[source]¶
Do a translation with the named translator and inputs
- Parameters
- transformer
DataTransformer transformer to execute
- output_key
str Output key. Used for generating the output’s identifier. Exclusive with output_identifier
- output_identifier
str Output identifier. Exclusive with output_key
- data_sources
listofDataSource Input data sources
- named_data_sources
dict Named input data sources
- transformer
- Raises
NoTranslatorFoundwhen a translator is not found
NoSourceFoundwhen a source cannot be looked up in the given context
ExtraSourceFoundwhen a more than one source is found in the given context for the given source identifier