Datasource API

API for working with the Datasource type.

Import this module like this:

from sympathy.api import datasource

Class datasource.File

class sympathy.typeutils.datasource.File(fileobj=None, data=None, filename=None, mode='r', scheme='hdf5', source=None, managed=False, import_links=False)[source]

A Datasource representing a sources of data. It can currently point to either a file on disk or to a database.

Any node port with the Datasource type will produce an object of this kind.

decode()[source]

Return the full dictionary for this data source.

decode_path()[source]

Return the path.

In a file data source this corresponds to the path of a file. In a data base data source this corresponds to a connection string. That can be used for accessing the data base. Returns None if path hasn’t been set.

Changed in version 1.2.5: Return None instead of raising KeyError if path hasn’t been set.

decode_type()[source]

Return the type of this data source.

It can be either 'FILE' or 'DATABASE'. Returns None if type hasn’t been set.

Changed in version 1.2.5: Return None instead of raising KeyError if type hasn’t been set.

encode(datasource_dict)[source]

Store the info from datasource_dict in this datasource.

Parameters:datasource_dict – should be a dictionary of the same format that you get from to_file_dict() or to_database_dict().
encode_database(*args, **kwargs)[source]

Store data base access info.

encode_path(filename)[source]

Store a path to a file in this datasource.

Parameters:filename – should be a string containing the path. Can be relative or absolute.
get()[source]

Return text data.

classmethod icon()[source]

Return full path to svg icon.

names(kind=None, **kwargs)[source]

Return a formatted list with a name and type of the data. columns.

set(data)[source]

Set text data.

static to_file_dict(fq_filename)[source]

Create a dictionary to be used for creating a file data source.

You usually want to use the convenience method encode_path() instead of calling this method directly.

types(kind=None, **kwargs)[source]

Return types associated with names.

classmethod viewer()[source]

Return viewer class, which must be a subclass of sympathy.api.typeutil.ViewerBase