wkps.wio package

Submodules

wkps.wio.basewkpio module

filename

sppas.src.wkps.wio.basewkpio.py

author

Laurent Vouriot, Brigitte Bigi

contact

develop@sppas.org

summary

Base class for any reader and writer of a workspace.

class wkps.wio.basewkpio.sppasBaseWkpIO(name=None)[source]

Bases: wkps.workspace.sppasWorkspace

Base class for any reader-writer of a workspace.

__init__(name=None)[source]

Initialize a new workspace reader-writer instance.

Parameters

name – (str) A workspace name

static detect(filename)[source]

Check whether a file is of an appropriate format or not.

read(filename)[source]

Read a file and fill the workspace.

Parameters

filename – (str)

set(wkp)[source]

Set the current workspace with the content of another one.

Parameters

wkp – (sppasWorkspace)

write(filename)[source]

Write a workspace into a file.

Parameters

filename – (str)

wkps.wio.wannotationpro module

filename

sppas.src.wkps.wio.wannotationpro.py

author

Laurent Vouriot, Brigitte Bigi

contact

develop@sppas.org

summary

A reader/writer of antw workspace file format.

An AnnotationPro workspace (antw) is an xml file

Here is an example of a very simple antw file

<?xml version=”1.0” standalone=”yes”?> <WorkspaceDataSet xmlns=”http://tempuri.org/WorkspaceDataSet.xsd”>

<WorkspaceItem>

<Id>b1b36c56-652c-4390-81ce-8eabd4b0260f</Id> <IdGroup>00000000-0000-0000-0000-000000000000</IdGroup> <Name>annprows.ant</Name> <OpenCount>0</OpenCount> <EditCount>4</EditCount> <ListenCount>5</ListenCount> <Accepted>false</Accepted>

</WorkspaceItem>

</WorkspaceDataSet>

<WorkspaceItem /> correspond to a file <Name /> is the name of the said file

each filename of the workspace got an id <Id /> a group id <idGroup /> and some information about the edition of the file how many times it has been opened <OpenCount />, how many editions (adding segment, layer, meta… each char typed count as an edition) <EditCount /> how many times it has been listened (played) <ListenCount /> <Accepted/> ?

class wkps.wio.wannotationpro.sppasWANT(name=None)[source]

Bases: sppas.src.wkps.wio.basewkpio.sppasBaseWkpIO

Reader and writer to import/export a workspace from/to annotationpro.

__init__(name=None)[source]

Initialize aa sppasWANT instance.

Parameters

name – (str) The name of the workspace

static detect(filename)[source]

Check whether a file is of antw format or not.

Parameters

filename – (str) Name of the file to detect

Returns

(bool)

static indent(elem, level=0)[source]

Pretty indent of an ElementTree.

http://effbot.org/zone/element-lib.htm#prettyprint

read(filename)[source]

Read a antw file and fill the sppasWANT instance.

Parameters

filename – (str)

write(filename)[source]

Write in the filename.

Parameters

filename – (str)

Returns

xml file

wkps.wio.wjson module

filename

sppas.src.wkps.wio.wjson.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

A reader/writer of wjson workspace file format.

class wkps.wio.wjson.sppasWJSON(name=None)[source]

Bases: wkps.wio.basewkpio.sppasBaseWkpIO

Reader and writer of a workspace in wjson format.

__init__(name=None)[source]

Initialize a sppasWJSON instance.

Parameters

name – (str) The name of the workspace

static detect(filename)[source]

Check whether a file is of wjson format or not.

Parameters

filename – (str) Name of the file to detect

Returns

(bool)

read(filename)[source]

Read a wjson file and fill the the sppasWSJON.

Parameters

filename – (str)

write(filename)[source]

Write in the filename.

Parameters

filename – (str)

wkps.wio.wkpreadwrite module

filename

sppas.src.wkps.wio.wkpreadwrite.py

author

Laurent Vouriot, Brigitte Bigi

contact

develop@sppas.org

summary

A reader/writer of any supported workspace file format.

class wkps.wio.wkpreadwrite.WkpFormatProperty(extension)[source]

Bases: object

Represent one format and its properties.

__init__(extension)[source]

Create a WkpFormatProperty instance.

Parameters

extension – (str) File name extension.

get_extension()[source]

Return the extension, including the initial dot.

get_reader()[source]

Return True if SPPAS can read files of the extension.

get_software()[source]

Return the name of the software matching the extension.

get_writer()[source]

Return True if SPPAS can write files of the extension.

class wkps.wio.wkpreadwrite.sppasWkpRW(filename)[source]

Bases: object

A reader/writer of any supported workspace file format.

WORKSPACE_TYPES = {'antw': <class 'wkps.wio.wannotationpro.sppasWANT'>, 'wjson': <class 'wkps.wio.wjson.sppasWJSON'>}
__init__(filename)[source]

Create a workspace reader/writer.

Parameters

filename – (str)

static create_wkp_from_extension(filename)[source]

Return a workspace according to a filename.

Parameters

filename – (str)

Returns

sppasBaseWkpIO()

static default_extension()[source]

Return the default extension to read/write workspaces.

static extensions()[source]

Return the list of supported extensions in lower case.

read()[source]

Read a workspace from a file.

Returns

(sppasWkpRW)

write(wkp)[source]

Write a workspace into a file.

Parameters

wkp – (sppasWorkspace) Data to be saved

Module contents

filename

sppas.src.wkps.wio.__init__.py

author

Laurent Vouriot, Brigitte Bigi

contact

develop@sppas.org

summary

Readers and writers of workspaces data.

class wkps.wio.WkpFormatProperty(extension)[source]

Bases: object

Represent one format and its properties.

__init__(extension)[source]

Create a WkpFormatProperty instance.

Parameters

extension – (str) File name extension.

get_extension()[source]

Return the extension, including the initial dot.

get_reader()[source]

Return True if SPPAS can read files of the extension.

get_software()[source]

Return the name of the software matching the extension.

get_writer()[source]

Return True if SPPAS can write files of the extension.

class wkps.wio.sppasWJSON(name=None)[source]

Bases: wkps.wio.basewkpio.sppasBaseWkpIO

Reader and writer of a workspace in wjson format.

__init__(name=None)[source]

Initialize a sppasWJSON instance.

Parameters

name – (str) The name of the workspace

static detect(filename)[source]

Check whether a file is of wjson format or not.

Parameters

filename – (str) Name of the file to detect

Returns

(bool)

read(filename)[source]

Read a wjson file and fill the the sppasWSJON.

Parameters

filename – (str)

write(filename)[source]

Write in the filename.

Parameters

filename – (str)

class wkps.wio.sppasWkpRW(filename)[source]

Bases: object

A reader/writer of any supported workspace file format.

WORKSPACE_TYPES = {'antw': <class 'wkps.wio.wannotationpro.sppasWANT'>, 'wjson': <class 'wkps.wio.wjson.sppasWJSON'>}
__init__(filename)[source]

Create a workspace reader/writer.

Parameters

filename – (str)

static create_wkp_from_extension(filename)[source]

Return a workspace according to a filename.

Parameters

filename – (str)

Returns

sppasBaseWkpIO()

static default_extension()[source]

Return the default extension to read/write workspaces.

static extensions()[source]

Return the list of supported extensions in lower case.

read()[source]

Read a workspace from a file.

Returns

(sppasWkpRW)

write(wkp)[source]

Write a workspace into a file.

Parameters

wkp – (sppasWorkspace) Data to be saved