PyOpenWorm.datasource module¶
-
class
PyOpenWorm.datasource.
BaseDataTranslator
(**kwargs)[source]¶ Bases:
PyOpenWorm.dataObject.DataObject
Translates from a data source to PyOpenWorm objects
-
input_type
¶ alias of
DataSource
-
output_type
¶ alias of
DataSource
-
translation_type
¶ alias of
Translation
-
make_translation
(self, sources=())[source]¶ It’s intended that implementations of DataTranslator will override this method to make custom Translations according with how different arguments to Translate are (or are not) distinguished.
The actual properties of a Translation subclass must be defined within the ‘translate’ method
-
-
class
PyOpenWorm.datasource.
DataObjectContextDataSource
(context, **kwargs)[source]¶ Bases:
PyOpenWorm.datasource.DataSource
- Input source :
ObjectProperty
Attribute: source
The data source that was translated into this one
- Translation :
ObjectProperty
Attribute: translation
Information about the translation process that created this object
- Description :
DatatypeProperty
Attribute: description
Free-text describing the data source
- Input source :
-
class
PyOpenWorm.datasource.
DataSource
(**kwargs)[source]¶ Bases:
PyOpenWorm.dataObject.DataObject
A source for data that can get translated into PyOpenWorm 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__.
-
commit
(self)[source]¶ Commit the data source locally
This includes staging files such as they would be available for a translation. In general, a sub-class should implement
commit_augment()
rather than this method, or at least call this method via superFor example, if the data source produces a file, that file should be in
-
defined_augment
(self)[source]¶ This fuction must return False if
identifier_augment()
would raise anIdentifierMissingException
. Override it when defining a non-standard identifier for subclasses of DataObjects.
-
identifier_augment
(self)[source]¶ Override this method to define an identifier in lieu of one explicity set.
One must also override
defined_augment()
to return True whenever this method could return a valid identifier.IdentifierMissingException
should be raised if an identifier cannot be generated by this method.Raises: - IdentifierMissingException
-
-
class
PyOpenWorm.datasource.
DataSourceType
(name, bases, dct)[source]¶ Bases:
PyOpenWorm.dataObject.ContextMappedClass
A type for DataSources
Sets up the graph with things needed for MappedClasses
-
class
PyOpenWorm.datasource.
DataTranslator
(**kwargs)[source]¶ Bases:
PyOpenWorm.datasource.BaseDataTranslator
A specialization with the
GenericTranslation
translation type that adds sources for the translation automatically when a new output is made-
translation_type
¶ alias of
GenericTranslation
-
make_translation
(self, sources=())[source]¶ It’s intended that implementations of DataTranslator will override this method to make custom Translations according with how different arguments to Translate are (or are not) distinguished.
The actual properties of a Translation subclass must be defined within the ‘translate’ method
-
-
class
PyOpenWorm.datasource.
GenericTranslation
(**kwargs)[source]¶ Bases:
PyOpenWorm.datasource.Translation
A generic translation that just has sources in order
-
defined_augment
(self)[source]¶ This fuction must return False if
identifier_augment()
would raise anIdentifierMissingException
. Override it when defining a non-standard identifier for subclasses of DataObjects.
-
identifier_augment
(self)[source]¶ Override this method to define an identifier in lieu of one explicity set.
One must also override
defined_augment()
to return True whenever this method could return a valid identifier.IdentifierMissingException
should be raised if an identifier cannot be generated by this method.Raises: - IdentifierMissingException
-
-
class
PyOpenWorm.datasource.
OneOrMore
(source_type)[source]¶ Bases:
object
Wrapper for
DataTranslator
inputDataSource
types indicating that one or more of the wrapped type must be provided to the translator
-
class
PyOpenWorm.datasource.
PersonDataTranslator
(**kwargs)[source]¶ Bases:
PyOpenWorm.datasource.BaseDataTranslator
A person who was responsible for carrying out the translation of a data source manually
-
person
¶ A person responsible for carrying out the translation.
-
-
class
PyOpenWorm.datasource.
Translation
(**kwargs)[source]¶ Bases:
PyOpenWorm.dataObject.DataObject
Representation of the method by which a DataSource was translated and the sources of that translation. Unlike the ‘source’ field attached to DataSources, the Translation may distinguish different kinds of input source to a translation.
-
defined_augment
(self)[source]¶ This fuction must return False if
identifier_augment()
would raise anIdentifierMissingException
. Override it when defining a non-standard identifier for subclasses of DataObjects.
-
identifier_augment
(self)[source]¶ Override this method to define an identifier in lieu of one explicity set.
One must also override
defined_augment()
to return True whenever this method could return a valid identifier.IdentifierMissingException
should be raised if an identifier cannot be generated by this method.Raises: - IdentifierMissingException
-