config package

Submodules

config.appcfg module

filename

sppas.src.config.appcfg.py

author

Florian Hocquet, Brigitte Bigi

contact

develop@sppas.org

summary

The application configuration.

class config.appcfg.sppasAppConfig[source]

Bases: object

Configuration for SPPAS application.

An instance of this class has to be created for any application using the SPPAS API.

Members are:

  • log_level

  • splash_delay

  • features dictionary

APP_CONFIG_FILENAME = '.app~'
DEFAULT_LOG_LEVEL = 0
__init__()[source]

Create a new sppasAppConfig instance.

The configuration is set to its default values and updated with the content of a configuration file (if existing).

The configuration is saved the 1st time this class is instantiated and when this class is deleted.

static cfg_filename()[source]

Return the name of the config file.

feature_installed(key)[source]

Return True if a feature was successfully installed by SPPAS.

Parameters

key – (str) Identifier of a feature.

get_feature_ids()[source]

Return the list of feature identifiers currently known.

get_log_level()[source]

Return the level for logging messages, ranging 0-50.

load()[source]

Load the configuration from a file.

property log_level

Return the level for logging messages, ranging 0-50.

save()[source]

Save into a JSON file.

set_feature(key, value)[source]

Add or update a feature.

This change is set to the current dict but is not saved in the configuration file.

Parameters
  • key – (str) Identifier of a feature

  • value – (bool) Installed or disabled

set_log_level(value)[source]

Set the log level for the application.

Parameters

value – (int) Logging ranges from 0 (any) to 50 (critical only).

config.exceptions module

filename

sppas.src.config.exceptions.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Global exceptions of SPPAS: a status is added.

Status of global exceptions for sppas:

  • main exception: 001

  • type errors: 100-series

  • index errors: 200-series

  • value errors: 300-series

  • key errors: 400-series

  • os errors: 500-series

  • IO errors: 600-series

exception config.exceptions.IOExtensionError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0610:.

Unknown extension for filename ‘{:s}’.

__init__(filename)[source]
exception config.exceptions.IndexRangeException(value, min_value, max_value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0340:.

List index {} out of range [{},{}].

__init__(value, min_value, max_value)[source]
exception config.exceptions.IntervalRangeException(value, min_value, max_value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0330:.

Value {} is out of range [{},{}].

__init__(value, min_value, max_value)[source]
exception config.exceptions.NegativeValueError(value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0310:.

Expected a positive value. Got {value}.

__init__(value)[source]
exception config.exceptions.NoDirectoryError(dirname)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0620:.

The directory {dirname} does not exist.

__init__(dirname)[source]
exception config.exceptions.RangeBoundsException(min_value, max_value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0320:.

Min value {} is bigger than max value {}.’

__init__(min_value, max_value)[source]
exception config.exceptions.sppasEnableFeatureError(name)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0520:.

Feature {name} is not enabled; its installation should be processed first.

__init__(name)[source]
exception config.exceptions.sppasError(message)[source]

Bases: Exception

:ERROR 0001:.

The following error occurred: {message}.

__init__(message)[source]
get_status()[source]
property status
exception config.exceptions.sppasExtensionReadError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0670:.

Files with extension ‘{:s}’ are not supported for reading.

__init__(filename)[source]
exception config.exceptions.sppasExtensionWriteError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0680:.

Files with extension ‘{:s}’ are not supported for writing.

__init__(filename)[source]
exception config.exceptions.sppasIOError(filename)[source]

Bases: OSError

:ERROR 0600:.

No such file or directory: {name}

__init__(filename)[source]
get_status()[source]
property status
exception config.exceptions.sppasIndexError(index)[source]

Bases: IndexError

:ERROR 0200:.

Invalid index value {:d}.

__init__(index)[source]
get_status()[source]
property status
exception config.exceptions.sppasInstallationError(error_msg)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0510:.

Installation failed with error: {error}.

__init__(error_msg)[source]
exception config.exceptions.sppasKeyError(data_name, value)[source]

Bases: KeyError

:ERROR 0400:.

Invalid key ‘{!s:s}’ for data ‘{!s:s}’.

__init__(data_name, value)[source]
get_status()[source]
property status
exception config.exceptions.sppasOSError(error_msg)[source]

Bases: OSError

:ERROR 0500:.

OS error: {error}.

__init__(error_msg)[source]
get_status()[source]
property status
exception config.exceptions.sppasOpenError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0650:.

File ‘{:s}’ can’t be open or read.

__init__(filename)[source]
exception config.exceptions.sppasPackageFeatureError(package, name)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0530:.

The package {package} can’t be imported. The installation of the feature {name} should be processed first.

__init__(package, name)[source]
exception config.exceptions.sppasPackageUpdateFeatureError(package, name)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0540:.

The package {package} is not up-to-date. The re-installation of the feature {name} should be processed first.”

__init__(package, name)[source]
exception config.exceptions.sppasPermissionError(error_msg)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0513:.

Permission error: access to {place} is denied.

__init__(error_msg)[source]
exception config.exceptions.sppasTypeError(rtype, expected)[source]

Bases: TypeError

:ERROR 0100:.

{!s:s} is not of the expected type ‘{:s}’.

__init__(rtype, expected)[source]
get_status()[source]
property status
exception config.exceptions.sppasValueError(data_name, value)[source]

Bases: ValueError

:ERROR 0300:.

Invalid value ‘{!s:s}’ for ‘{!s:s}’.

__init__(data_name, value)[source]
get_status()[source]
property status
exception config.exceptions.sppasWriteError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0660:.

File ‘{:s}’ can’t be saved.

__init__(filename)[source]

config.logs module

filename

sppas.src.config.logs.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Log system of SPPAS.

class config.logs.sppasLogFile(pattern='log')[source]

Bases: object

Manager for logs of SPPAS runs.

__init__(pattern='log')[source]

Create a sppasLogFile instance.

Create the log directory if it not already exists then fix the log filename with increment=0.

get_filename()[source]

Return the current log filename.

static get_header()[source]

Return a string with an header for logs.

increment()[source]

Increment the current log filename.

class config.logs.sppasLogSetup(log_level=0)[source]

Bases: object

A convenient class to initialize the python logging system.

__init__(log_level=0)[source]

Create a sppasLogSetup instance.

By default, the NullHandler is assigned: no output. The numeric values of logging levels are the followings:

  • CRITICAL 50

  • ERROR 40

  • WARNING 30

  • INFO 20

  • DEBUG 10

  • NOTSET 0

Logging messages which are less severe than the given level value will be ignored. When NOTSET is assigned, all messages are printed.

Parameters

log_level – Set the threshold logger value

file_handler(filename)[source]

Start to redirect to logging FileHandler.

Parameters

filename – a FileHandler has to be created using this filename.

null_handler()[source]

Start to redirect to logging NullHandler.

set_log_level(log_level)[source]

Fix the log level.

Parameters

log_level – Set the threshold for the logger

stream_handler()[source]

Start to redirect to logging StreamHandler.

config.makeunicode module

filename

sppas.src.config.makeunicode.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Utilities for unicode.

makeunicode is useful for the compatibility of strings between Python 2.7 and Python > 3.2.

>>> token = "  

   ỏ  "
>>> sp = sppasUnicode(token)
>>> token = sp.to_strip()
>>> token == u('Ỹ ỏ')
>>> True
config.makeunicode.b(x)[source]

Convert to byte using encode().

Parameters

x – a unicode string

Returns

a string

class config.makeunicode.sppasUnicode(entry)[source]

Bases: object

Make a string as unicode and operates on it.

__init__(entry)[source]

Create a sppasUnicode instance.

Parameters

entry – (str or unicode or bytes in python 2)

clear_whitespace()[source]

Replace the whitespace by underscores.

Returns

unicode

is_restricted_ascii()[source]

Check if the entry key is using only a-Z_ characters.

Returns

(bool)

to_ascii()[source]

Replace the non-ASCII characters by underscores.

Returns

unicode

to_lower()[source]

Return the unicode string with lower case.

Returns

unicode

to_strip()[source]

Strip the string.

Remove also multiple whitespace, tab and CR/LF inside the string.

Returns

unicode

unicode()[source]

Return the unicode string of the given entry.

Returns

unicode

config.makeunicode.u(x)[source]

Convert to unicode (i.e. do nothing).

Parameters

x – a string

Returns

a unicode string

config.po module

filename

sppas.src.config.po.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Translation system of SPPAS.

class config.po.T[source]

Bases: object

Utility class to mimic the GNUTranslations class.

Backward compatibility of Python 2.7.

static gettext(message)[source]

Return msg in unicode.

static ugettext(message)[source]

Return msg.

config.po.error(msg_id, domain=None)[source]

Return the error message from gettext.

Parameters
  • msg_id – (str or int) Error id

  • domain – (str) Name of the domain

config.po.info(msg_id, domain=None)[source]

Return the info message from gettext.

Parameters
  • msg_id – (str or int) Info id

  • domain – (str) Name of the domain

config.po.msg(msg, domain=None)[source]

Return the message from gettext.

Parameters
  • msg – (str) Message

  • domain – (str) Name of the domain

class config.po.sppasTranslate[source]

Bases: object

Fix the domain to translate messages and to activate the gettext method.

sppasTranslate is useful for the internationalization of texts. The locale is used to set the language but English is the default. The path to search for a domain translation is the one of the ‘po’ folder.

Example
>>> _ = sppasTranslate().translation("domain").gettext
>>> my_string = _("Some string in the domain.")
DEFAULT_LOCALE = ['en']
__init__()[source]

Create a sppasTranslate instance.

Fix languages.

static get_lang_list()[source]

Return the list of languages depending on the default locale.

At a first stage, the language is fixed with the default locale. English is then either appended to the list or used by default.

translation(domain)[source]

Create the GNUTranslations for a given domain.

A domain corresponds to a .po file of the language in the ‘po’ folder of the SPPAS package.

Parameters

domain – (str) Name of the domain.

Returns

(GNUTranslations)

config.process module

filename

sppas.src.config.process.py

authors

Florian Hocquet, Brigitte Bigi

contact

develop@sppas.org

summary

Execute a subprocess and get results.

class config.process.Process[source]

Bases: object

A convenient class to execute a subprocess.

A Process is a wrapper of subprocess.Popen command.

Launch a command:
>>> p = Process()
>>> p.run_popen("ls -l")
Return the stdout of the command:
>>> p.out()
Return the stderr of the command:
>>> p.error()
Stop a command:
>>> p.stop()
Return the state of the command:
>>> p.is_running()
__init__()[source]

Create a new instance.

error()[source]

Return the error output of the process.

Returns

(str) error message

is_running()[source]

Return True if the process is still running.

Returns

(bool)

out()[source]

Return the standard output of the process.

Returns

(str) output message

run(command, timeout=120)[source]

Execute command with subprocess.run.

Parameters
  • command – (str) The command to execute

  • timeout – (int) Will raise TimeoutExpired() after timeout seconds

run_popen(command)[source]

Execute the given command with subprocess.Popen.

Parameters

command – (str) The command to be executed

status()[source]

Return the status of the command if the process is completed.

Returns

(int) -2 is no process

stop()[source]

Terminate the process if it is running.

static test_command(command)[source]

Return True if command exists.

Test only the main command (i.e. the first string, without args).

config.settings module

filename

sppas.src.config.settings.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Store global modifiable or non-modifiable members.

class config.settings.sppasAnnotationsSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable settings of annotations.

__init__()[source]

Create the sppasAnnotationsSettings dictionary.

class config.settings.sppasBaseSettings[source]

Bases: object

Base class to manage any kind of settings, represented in a dictionary.

A base class for any configuration or settings. Allows to store modifiable or un-modifiable members - by declaring a set() method, and to load/save them from/to a file each time the instance is created/deleted.

Example

>>>with sppasBaseSettings() as settings: >>> settings.newKey = ‘myNewValue’ >>> print(settings.newKey)

__init__()[source]

Create the dictionary and load config file if any.

load()[source]

Load the dictionary of settings from a file.

To be overridden.

save()[source]

Save the dictionary of settings in a file.

To be overridden.

class config.settings.sppasGlobalSettings[source]

Bases: object

Representation of global non-modifiable settings of SPPAS.

Includes the version, name, author, copyright, etc. These global settings are loaded from a JSON file.

__init__()[source]

Create the dictionary and load the main config file.

load()[source]

Load the dictionary of settings from a file.

class config.settings.sppasPathSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable paths of SPPAS.

__init__()[source]

Create the sppasPathSettings dictionary.

class config.settings.sppasSeparatorSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable separators of SPPAS.

__init__()[source]

Create the sppasSeparatorSettings dictionary.

class config.settings.sppasSymbolSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable symbols of SPPAS.

This class defines:

  • unk: the default symbol used by annotations and resources to represent unknown entries

  • ortho: symbols used in an orthographic transcription, or after a text normalization

  • phone: symbols used to represent events in grapheme to phoneme conversion.

  • all: ortho+phone (i.e. all known symbols)

__init__()[source]

Create the sppasSymbolSettings dictionary.

config.support module

filename

sppas.src.config.support.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Support of SPPAS. Currently under development.

class config.support.sppasPostInstall[source]

Bases: object

Check directories and create if not existing.

static sppas_dependencies()[source]

Enable or disable features depending on dependencies.

static sppas_directories()[source]

Create the required directories in the SPPAS package.

Raise

sppasPermissionError

class config.support.sppasUpdate[source]

Bases: object

Check if an update of SPPAS is available.

This class is not implemented yet.

static check_update()[source]

config.trash module

filename

sppas.src.config.trash.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

The application trash for backup files.

class config.trash.sppasTrash[source]

Bases: object

Utility manager of the Trash of SPPAS.

__init__()[source]

Create a sppasTrash instance.

Create the trash directory if not already existing.

do_empty()[source]

Empty the trash, i.e. definitely delete all files.

is_empty()[source]

Return True if the trash is empty.

put_file_into(filename)[source]

Put a file into the trash.

Parameters

filename – (str)

Returns

Full name of the file in the trash

put_folder_into(folder)[source]

Put a folder into the trash.

Parameters

folder – (str)

Module contents

filename

sppas.src.config.__init__.py

author

Brigitte Bigi

contact

develop@sppas.org

summary

Package for the configuration of SPPAS.

config: configuration & globals of SPPAS

This package includes classes to fix all global parameters. It does not requires any other package but all other packages of SPPAS are requiring it!

All classes of this package are compatible with any version of python.

exception config.IOExtensionError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0610:.

Unknown extension for filename ‘{:s}’.

__init__(filename)[source]
exception config.IndexRangeException(value, min_value, max_value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0340:.

List index {} out of range [{},{}].

__init__(value, min_value, max_value)[source]
exception config.IntervalRangeException(value, min_value, max_value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0330:.

Value {} is out of range [{},{}].

__init__(value, min_value, max_value)[source]
exception config.NegativeValueError(value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0310:.

Expected a positive value. Got {value}.

__init__(value)[source]
exception config.NoDirectoryError(dirname)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0620:.

The directory {dirname} does not exist.

__init__(dirname)[source]
class config.Process[source]

Bases: object

A convenient class to execute a subprocess.

A Process is a wrapper of subprocess.Popen command.

Launch a command:
>>> p = Process()
>>> p.run_popen("ls -l")
Return the stdout of the command:
>>> p.out()
Return the stderr of the command:
>>> p.error()
Stop a command:
>>> p.stop()
Return the state of the command:
>>> p.is_running()
__init__()[source]

Create a new instance.

error()[source]

Return the error output of the process.

Returns

(str) error message

is_running()[source]

Return True if the process is still running.

Returns

(bool)

out()[source]

Return the standard output of the process.

Returns

(str) output message

run(command, timeout=120)[source]

Execute command with subprocess.run.

Parameters
  • command – (str) The command to execute

  • timeout – (int) Will raise TimeoutExpired() after timeout seconds

run_popen(command)[source]

Execute the given command with subprocess.Popen.

Parameters

command – (str) The command to be executed

status()[source]

Return the status of the command if the process is completed.

Returns

(int) -2 is no process

stop()[source]

Terminate the process if it is running.

static test_command(command)[source]

Return True if command exists.

Test only the main command (i.e. the first string, without args).

exception config.RangeBoundsException(min_value, max_value)[source]

Bases: config.exceptions.sppasValueError

:ERROR 0320:.

Min value {} is bigger than max value {}.’

__init__(min_value, max_value)[source]
config.b(x)[source]

Convert to byte using encode().

Parameters

x – a unicode string

Returns

a string

config.error(msg_id, domain=None)[source]

Return the error message from gettext.

Parameters
  • msg_id – (str or int) Error id

  • domain – (str) Name of the domain

config.info(msg_id, domain=None)[source]

Return the info message from gettext.

Parameters
  • msg_id – (str or int) Info id

  • domain – (str) Name of the domain

config.msg(msg, domain=None)[source]

Return the message from gettext.

Parameters
  • msg – (str) Message

  • domain – (str) Name of the domain

class config.sppasAnnotationsSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable settings of annotations.

__init__()[source]

Create the sppasAnnotationsSettings dictionary.

class config.sppasAppConfig[source]

Bases: object

Configuration for SPPAS application.

An instance of this class has to be created for any application using the SPPAS API.

Members are:

  • log_level

  • splash_delay

  • features dictionary

APP_CONFIG_FILENAME = '.app~'
DEFAULT_LOG_LEVEL = 0
__init__()[source]

Create a new sppasAppConfig instance.

The configuration is set to its default values and updated with the content of a configuration file (if existing).

The configuration is saved the 1st time this class is instantiated and when this class is deleted.

static cfg_filename()[source]

Return the name of the config file.

feature_installed(key)[source]

Return True if a feature was successfully installed by SPPAS.

Parameters

key – (str) Identifier of a feature.

get_feature_ids()[source]

Return the list of feature identifiers currently known.

get_log_level()[source]

Return the level for logging messages, ranging 0-50.

load()[source]

Load the configuration from a file.

property log_level

Return the level for logging messages, ranging 0-50.

save()[source]

Save into a JSON file.

set_feature(key, value)[source]

Add or update a feature.

This change is set to the current dict but is not saved in the configuration file.

Parameters
  • key – (str) Identifier of a feature

  • value – (bool) Installed or disabled

set_log_level(value)[source]

Set the log level for the application.

Parameters

value – (int) Logging ranges from 0 (any) to 50 (critical only).

class config.sppasBaseSettings[source]

Bases: object

Base class to manage any kind of settings, represented in a dictionary.

A base class for any configuration or settings. Allows to store modifiable or un-modifiable members - by declaring a set() method, and to load/save them from/to a file each time the instance is created/deleted.

Example

>>>with sppasBaseSettings() as settings: >>> settings.newKey = ‘myNewValue’ >>> print(settings.newKey)

__init__()[source]

Create the dictionary and load config file if any.

load()[source]

Load the dictionary of settings from a file.

To be overridden.

save()[source]

Save the dictionary of settings in a file.

To be overridden.

exception config.sppasEnableFeatureError(name)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0520:.

Feature {name} is not enabled; its installation should be processed first.

__init__(name)[source]
exception config.sppasError(message)[source]

Bases: Exception

:ERROR 0001:.

The following error occurred: {message}.

__init__(message)[source]
get_status()[source]
property status
exception config.sppasExtensionReadError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0670:.

Files with extension ‘{:s}’ are not supported for reading.

__init__(filename)[source]
exception config.sppasExtensionWriteError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0680:.

Files with extension ‘{:s}’ are not supported for writing.

__init__(filename)[source]
class config.sppasGlobalSettings[source]

Bases: object

Representation of global non-modifiable settings of SPPAS.

Includes the version, name, author, copyright, etc. These global settings are loaded from a JSON file.

__init__()[source]

Create the dictionary and load the main config file.

load()[source]

Load the dictionary of settings from a file.

exception config.sppasIOError(filename)[source]

Bases: OSError

:ERROR 0600:.

No such file or directory: {name}

__init__(filename)[source]
get_status()[source]
property status
exception config.sppasIndexError(index)[source]

Bases: IndexError

:ERROR 0200:.

Invalid index value {:d}.

__init__(index)[source]
get_status()[source]
property status
exception config.sppasInstallationError(error_msg)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0510:.

Installation failed with error: {error}.

__init__(error_msg)[source]
exception config.sppasKeyError(data_name, value)[source]

Bases: KeyError

:ERROR 0400:.

Invalid key ‘{!s:s}’ for data ‘{!s:s}’.

__init__(data_name, value)[source]
get_status()[source]
property status
class config.sppasLogFile(pattern='log')[source]

Bases: object

Manager for logs of SPPAS runs.

__init__(pattern='log')[source]

Create a sppasLogFile instance.

Create the log directory if it not already exists then fix the log filename with increment=0.

get_filename()[source]

Return the current log filename.

static get_header()[source]

Return a string with an header for logs.

increment()[source]

Increment the current log filename.

class config.sppasLogSetup(log_level=0)[source]

Bases: object

A convenient class to initialize the python logging system.

__init__(log_level=0)[source]

Create a sppasLogSetup instance.

By default, the NullHandler is assigned: no output. The numeric values of logging levels are the followings:

  • CRITICAL 50

  • ERROR 40

  • WARNING 30

  • INFO 20

  • DEBUG 10

  • NOTSET 0

Logging messages which are less severe than the given level value will be ignored. When NOTSET is assigned, all messages are printed.

Parameters

log_level – Set the threshold logger value

file_handler(filename)[source]

Start to redirect to logging FileHandler.

Parameters

filename – a FileHandler has to be created using this filename.

null_handler()[source]

Start to redirect to logging NullHandler.

set_log_level(log_level)[source]

Fix the log level.

Parameters

log_level – Set the threshold for the logger

stream_handler()[source]

Start to redirect to logging StreamHandler.

exception config.sppasOpenError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0650:.

File ‘{:s}’ can’t be open or read.

__init__(filename)[source]
exception config.sppasPackageFeatureError(package, name)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0530:.

The package {package} can’t be imported. The installation of the feature {name} should be processed first.

__init__(package, name)[source]
exception config.sppasPackageUpdateFeatureError(package, name)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0540:.

The package {package} is not up-to-date. The re-installation of the feature {name} should be processed first.”

__init__(package, name)[source]
class config.sppasPathSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable paths of SPPAS.

__init__()[source]

Create the sppasPathSettings dictionary.

exception config.sppasPermissionError(error_msg)[source]

Bases: config.exceptions.sppasOSError

:ERROR 0513:.

Permission error: access to {place} is denied.

__init__(error_msg)[source]
class config.sppasPostInstall[source]

Bases: object

Check directories and create if not existing.

static sppas_dependencies()[source]

Enable or disable features depending on dependencies.

static sppas_directories()[source]

Create the required directories in the SPPAS package.

Raise

sppasPermissionError

class config.sppasSeparatorSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable separators of SPPAS.

__init__()[source]

Create the sppasSeparatorSettings dictionary.

class config.sppasSymbolSettings[source]

Bases: config.settings.sppasBaseSettings

Representation of global non-modifiable symbols of SPPAS.

This class defines:

  • unk: the default symbol used by annotations and resources to represent unknown entries

  • ortho: symbols used in an orthographic transcription, or after a text normalization

  • phone: symbols used to represent events in grapheme to phoneme conversion.

  • all: ortho+phone (i.e. all known symbols)

__init__()[source]

Create the sppasSymbolSettings dictionary.

class config.sppasTrash[source]

Bases: object

Utility manager of the Trash of SPPAS.

__init__()[source]

Create a sppasTrash instance.

Create the trash directory if not already existing.

do_empty()[source]

Empty the trash, i.e. definitely delete all files.

is_empty()[source]

Return True if the trash is empty.

put_file_into(filename)[source]

Put a file into the trash.

Parameters

filename – (str)

Returns

Full name of the file in the trash

put_folder_into(folder)[source]

Put a folder into the trash.

Parameters

folder – (str)

exception config.sppasTypeError(rtype, expected)[source]

Bases: TypeError

:ERROR 0100:.

{!s:s} is not of the expected type ‘{:s}’.

__init__(rtype, expected)[source]
get_status()[source]
property status
class config.sppasUnicode(entry)[source]

Bases: object

Make a string as unicode and operates on it.

__init__(entry)[source]

Create a sppasUnicode instance.

Parameters

entry – (str or unicode or bytes in python 2)

clear_whitespace()[source]

Replace the whitespace by underscores.

Returns

unicode

is_restricted_ascii()[source]

Check if the entry key is using only a-Z_ characters.

Returns

(bool)

to_ascii()[source]

Replace the non-ASCII characters by underscores.

Returns

unicode

to_lower()[source]

Return the unicode string with lower case.

Returns

unicode

to_strip()[source]

Strip the string.

Remove also multiple whitespace, tab and CR/LF inside the string.

Returns

unicode

unicode()[source]

Return the unicode string of the given entry.

Returns

unicode

exception config.sppasValueError(data_name, value)[source]

Bases: ValueError

:ERROR 0300:.

Invalid value ‘{!s:s}’ for ‘{!s:s}’.

__init__(data_name, value)[source]
get_status()[source]
property status
exception config.sppasWriteError(filename)[source]

Bases: config.exceptions.sppasIOError

:ERROR 0660:.

File ‘{:s}’ can’t be saved.

__init__(filename)[source]
config.u(x)[source]

Convert to unicode (i.e. do nothing).

Parameters

x – a string

Returns

a unicode string