specio.core.FormatManager

class specio.core.FormatManager[source][source]

Format manager containing all the registered formats.

There is exactly one FormatManager object in specio: specio.formats. Its purpose it to keep track of the registered formats.

The format manager supports getting a format object using indexing (by format name or extension). When used as an iterator, this object yields all registered format objects.

__init__()[source][source]

Methods

__init__()
add_format(format[, overwrite]) Register a given format.
get_format_names() Get the names of all registered formats.
search_read_format(request) Search a specific format.
show() Show a nicely formatted list of available formats.
sort(*names) Sort the registered format.
add_format(format, overwrite=False)[source][source]

Register a given format.

Parameters:

format : specio.Format

The format to be registered.

overwrite : bool, (default=False)

If False, a format with the same name will raise an error. If True, it will replace it.

Returns:

None

get_format_names()[source][source]

Get the names of all registered formats.

search_read_format(request)[source][source]

Search a specific format.

Search a format that can read a file according to the given request.

Parameters:

request : specio.Request

The request to read a specific resource.

Returns:

format : specio.Format or None

Returns the specio.Format found or None if no appropriate format was found.

show()[source][source]

Show a nicely formatted list of available formats.

sort(*names)[source][source]

Sort the registered format.

Sort the formats based on zero or more given names; a format with a name that matches one of the given names will take precedence over other formats. A match means an equal name, or ending with that name (though the former counts higher). Case insensitive.

Be aware that using the function can affect the behavior of other code that makes use of specio.

Parameters:

names : list of str

Sequence of format name which need to be sorted.

Returns:

None