Utils

utils.*

class ts2.utils.Context[source]

Bases: object

Different context’s

EDITORS = [20, 21, 22, 23, 24, 25]

Editor Modes list

EDITOR_GENERAL = 20

Editor General

EDITOR_ROUTES = 22

Editor Routes

EDITOR_SCENERY = 21

Editor Scenery

EDITOR_SERVICES = 24

Editor Services

EDITOR_TRAINS = 25

Editor Trains

EDITOR_TRAINTYPES = 23

Editor TrainTypes

GAME = 10

Game

__weakref__

list of weak references to the object (if defined)

class ts2.utils.DurationProba(data)[source]

Bases: PyQt5.QtCore.QObject

A DurationProba is a probability distribution for a duration in seconds.

__init__(data)[source]

Constructor for the DurationProba class.

__str__()[source]

Returns the string representation of the DurationProba.

isNull()[source]

Returns true if the DurationProba instance has no data.

yieldValue()[source]

Returns a random value in the bounds and probabilities given by this DurationProba instance.

exception ts2.utils.FormatException(arg)[source]

Bases: Exception

File format exception.

__init__(arg)[source]

Constructor of the FormatException class.

__weakref__

list of weak references to the object (if defined)

exception ts2.utils.MissingDependencyException(arg)[source]

Bases: Exception

Exception raised when a dependency is missing (e.g. TSL file).

__init__(arg)[source]

Constructor of the MissingDependencyException class.

__weakref__

list of weak references to the object (if defined)

ts2.utils.cumsum(lis)[source]

cumulated sum of lis

Returns:a list with the
ts2.utils.from_json(json_str)[source]

Load data from a json string

ts2.utils.settings = <ts2.xobjects.xsettings.XSettings object>

Settings instance

ts2.utils.to_json(data)[source]

Serialize data to a json string

Important

Its advised to use this function as its is indented and

sorted and therefore a consistent output. This is for git and versioning reasons, ie less deltas.