opentps.core.utils package

Submodules

opentps.core.utils.applicationConfig module

class AbstractApplicationConfig(*args, **kwargs)

Bases: object

Abstract class for application configuration. This class is a singleton.

Variables:

configFile (str) – Path to the configuration file.

getConfigField(section: str, field: str, defaultValue: Any) str

Get a configuration field from the configuration file. If the field does not exist, it will be created with the default value.

Parameters:
  • section (str) – Section of the configuration file.

  • field (str) – Field of the configuration file.

  • defaultValue (Any) – Default value of the field.

Returns:

Configuration of the field.

Return type:

str

setConfigField(section: str, field: str, value: Any)

Set a configuration field from the configuration file.

Parameters:
  • section (str) – Section of the configuration file.

  • field (str) – Field of the configuration file.

  • value (Any) – Value of the field.

Returns:

Configuration of the field.

Return type:

str

writeConfig()

Write the configuration file.

Returns:

Configuration of the field.

Return type:

str

opentps.core.utils.pickel2 module

Create portable serialized representations of Python objects.

See module copyreg for a mechanism for registering custom picklers. See module pickletools source for extensive comments.

Classes:

Pickler Unpickler

Functions:

dump(object, file) dumps(object) -> string load(file) -> object loads(bytes) -> object

Misc variables:

__version__ format_version compatible_formats

exception PickleError

Bases: Exception

A common base class for the other pickling exceptions.

exception PicklingError

Bases: PickleError

This exception is raised when an unpicklable object is passed to the dump() method.

exception UnpicklingError

Bases: PickleError

This exception is raised when there is a problem unpickling an object, such as a security violation.

Note that other exceptions may also be raised during unpickling, including (but not necessarily limited to) AttributeError, EOFError, ImportError, and IndexError.

decode_long(data)

Decode a long from a two’s complement little-endian binary string.

>>> decode_long(b'')
0
>>> decode_long(b"\xff\x00")
255
>>> decode_long(b"\xff\x7f")
32767
>>> decode_long(b"\x00\xff")
-256
>>> decode_long(b"\x00\x80")
-32768
>>> decode_long(b"\x80")
-128
>>> decode_long(b"\x7f")
127
encode_long(x)

Encode a long to a two’s complement little-endian binary string. Note that 0 is a special case, returning an empty string, to save a byte in the LONG1 pickling context.

>>> encode_long(0)
b''
>>> encode_long(255)
b'\xff\x00'
>>> encode_long(32767)
b'\xff\x7f'
>>> encode_long(-256)
b'\x00\xff'
>>> encode_long(-32768)
b'\x00\x80'
>>> encode_long(-128)
b'\x80'
>>> encode_long(127)
b'\x7f'
>>>
load(file, *, fix_imports=True, encoding='ASCII', errors='strict', buffers=None)
loads(s, /, *, fix_imports=True, encoding='ASCII', errors='strict', buffers=None)
whichmodule(obj, name)

Find the module an object belong to.

opentps.core.utils.programSettings module

class ProgramSettings(*args, **kwargs)

Bases: object

This class is a singleton and should be used to get the program settings.

The program settings are stored in a config file in the user’s config directory.

The config file is created if it does not exist.

Variables:
  • programSettingsFolder (str) – The folder where the program settings are stored.

  • workspace (str) – The folder where the workspace is located.

  • startScriptFolder (str) – The folder where the start scripts are located.

  • simulationFolder (str) – The folder where the simulations are located.

  • loggingConfigFile (str) – The path to the logging config file.

  • resultFolder (str) – The folder where the results are located.

  • logFolder (str) – The folder where the logs are located.

  • exampleFolder (str) – The folder where the examples are located.

property exampleFolder
property logFolder
property loggingConfigFile
property programSettingsFolder
property resultFolder
property simulationFolder
property startScriptFolder
property workspace
writeConfig()

Write the config to the config file.

class Singleton

Bases: type

Module contents