yatel.yio package

Submodules

yatel.yio.core module

Base structure for Yatel parsers.

class yatel.yio.core.BaseParser[source]

Bases: object

Base class for parsers.

dump(nw, fp, *args, **kwargs)[source]

Abstract Method.

Serializes data from a yatel network to a file.

Raises:NotImplementedError
dumps(nw, *args, **kwargs)[source]

Serializes a yatel db to a formatted string.

Parameters:

nw : yatel.db.YatelNetwork

Network source of data.

Returns:

string : str

Json formatted string.

classmethod file_exts()[source]
load(nw, fp, *args, **kwargs)[source]

Abstract Method.

Deserializes data from a file and adds it to the yatel network.

Raises:NotImplementedError
loads(nw, string, *args, **kwargs)[source]

Deserializes a formatted string to add it into the yatel database.

Parameters:

nw : yatel.db.YatelNetwork

Network destination for data.

string : str

String to be deserialize.

classmethod version()[source]

Returns version of parser.

yatel.yio.core.YF_STR_VERSION = '0.5'

Parser version number (string).

yatel.yio.core.YF_VERSION = ('0', '5')

Parser version number (tuple).

yatel.yio.yjf module

Persists Yatel databases in json format.

class yatel.yio.yjf.JSONParser[source]

Bases: yatel.yio.core.BaseParser

JSON parser to serialize and deserialize data.

dump(nw, fp, *args, **kwargs)[source]

Serializes data from a Yatel network to a JSON file-like stream.

Parameters:

nw : yatel.db.YatelNetwork

Network source of data.

fp : file-like object

Target for serialization.

classmethod file_exts()[source]

Returns extensions used for JSON handling.

load(nw, fp, *args, **kwargs)[source]

Deserializes data from a JSON file-like stream and adds it to the yatel network.

Parameters:

nw : yatel.db.YatelNetwork

Network target of data.

fp : file-like object

Source of data to deserialize.

yatel.yio.yxf module

Persists Yatel databases in XML format.

class yatel.yio.yxf.XMLParser[source]

Bases: yatel.yio.core.BaseParser

XML parser to serialize and deserialize data.

dump(nw, fp, *args, **kwargs)[source]

Serializes data from a Yatel network to a XML file-like stream.

Parameters:

nw : yatel.db.YatelNetwork

Network source of data.

fp : file-like object

Target for serialization.

classmethod file_exts()[source]

Returns extensions used for XML handling.

load(nw, fp, *args, **kwargs)[source]

Deserializes data from a XML file-like stream and adds it to the Yatel network.

Parameters:

nw : yatel.db.YatelNetwork

Network target of data.

fp : file-like object

Source of data to deserialize.

Module contents

Utilities to persist yatel into diferent file formats.

yatel.yio.PARSERS = {'xml': <class 'yatel.yio.yxf.XMLParser'>, 'json': <class 'yatel.yio.yjf.JSONParser'>, 'yxf': <class 'yatel.yio.yxf.XMLParser'>, 'yjf': <class 'yatel.yio.yjf.JSONParser'>}

Container of the different parsers supported by Yatel.

yatel.yio.SYNONYMS = frozenset([('json', 'yjf'), ('xml', 'yxf')])

Synonyms of the names used by the parser.

yatel.yio.dump(ext, nw, stream=None, *args, **kwargs)[source]

Serializes from a Yatel network to a file or string.

Parameters:

ext : str

Extension of target data.

nw : yatel.db.YatelNetwork

Source database.

stream : file or str

Target of data, can be string or a file.

yatel.yio.load(ext, nw, stream, *args, **kwargs)[source]

Deserializes from a stream to Yatel network.

Parameters:

ext : str

Extension of source data.

nw : yatel.db.YatelNetwork

Target database.

stream : file or str

Source of data, can be string or file.