Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 48 additions & 43 deletions PySimLib/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,61 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

from PySimLib.Platform import *;
from PySimLib.Platform import *

# Public


#Public
def GetBoolConfigValue(section, key):
global __g_sections;

return __g_sections[section][key] == "true";

global __g_sections

return __g_sections[section][key] == "true"


def GetConfigValue(section, key):
global __g_sections;

return __g_sections[section][key];

global __g_sections

return __g_sections[section][key]


def HasConfigValue(section, key):
global __g_sections;

if(section in __g_sections):
return key in __g_sections[section];

return False;
global __g_sections

if(section in __g_sections):
return key in __g_sections[section]

return False



#Internal
__g_sections = {};
# Internal
__g_sections = {}


def ReadConfigFromFile():
import os;
import os.path;
import configparser;

global __g_sections;

path = GetConfigDirectory() + '/PySimLib.cfg';

if(not os.path.isfile(path)):
raise Exception("PySimLib is not configured. Please read the manual to do so.");

parser = configparser.ConfigParser();
parser.optionxform = str; #disable lower caseing
parser.read(path);

for section in parser.sections():
entries = {};
for key in parser.options(section):
entries[key] = parser[section][key];

if(len(entries) > 0):
__g_sections[section] = entries;

#read config
ReadConfigFromFile();
import os
import os.path
import configparser

global __g_sections

path = GetConfigDirectory() + '/PySimLib.cfg'

if(not os.path.isfile(path)):
raise Exception("PySimLib is not configured. Please read the manual to do so.")

parser = configparser.ConfigParser()
parser.optionxform = str # disable lower caseing
parser.read(path)

for section in parser.sections():
entries = {}
for key in parser.options(section):
entries[key] = parser[section][key]

if(len(entries) > 0):
__g_sections[section] = entries


# read config
ReadConfigFromFile()
23 changes: 12 additions & 11 deletions PySimLib/Exceptions/CompilationFailedException.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


class CompilationFailedException(Exception):
#Constructor
def __init__(this, mdl, tool):
Exception.__init__(this);
#Private members
this.__mdl = mdl;
this.__tool = tool;
#Magic methods
def __str__(this):
return 'Compilation of model "' + str(this.__mdl) + '" with tool "' + str(this.__tool) + '" failed.';
# Constructor
def __init__(this, mdl, tool):
Exception.__init__(this)

# Private members
this.__mdl = mdl
this.__tool = tool

# Magic methods
def __str__(this):
return 'Compilation of model "' + str(this.__mdl) + '" with tool "' + str(this.__tool) + '" failed.'
23 changes: 12 additions & 11 deletions PySimLib/Exceptions/SimulationFailedException.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


class SimulationFailedException(Exception):
#Constructor
def __init__(this, sim, tool):
Exception.__init__(this);
#Private members
this.__sim = sim;
this.__tool = tool;
#Magic methods
def __str__(this):
return 'Simulation of model "' + str(this.__sim.GetModel()) + '" with tool "' + str(this.__tool) + '" failed.';
# Constructor
def __init__(this, sim, tool):
Exception.__init__(this)

# Private members
this.__sim = sim
this.__tool = tool

# Magic methods
def __str__(this):
return 'Simulation of model "' + str(this.__sim.GetModel()) + '" with tool "' + str(this.__tool) + '" failed.'
23 changes: 12 additions & 11 deletions PySimLib/Exceptions/UncompiledModelException.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


class UncompiledModelException(Exception):
#Constructor
def __init__(this, mdl, tool):
Exception.__init__(this);
#Private members
this.__mdl = mdl;
this.__tool = tool;
#Magic methods
def __str__(this):
return 'Model "' + str(this.__mdl) + '" is being used with tool "' + str(this.__tool) + '" but is not compiled.';
# Constructor
def __init__(this, mdl, tool):
Exception.__init__(this)

# Private members
this.__mdl = mdl
this.__tool = tool

# Magic methods
def __str__(this):
return 'Model "' + str(this.__mdl) + '" is being used with tool "' + str(this.__tool) + '" but is not compiled.'
44 changes: 25 additions & 19 deletions PySimLib/Log.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,34 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

#Global
import os;
# Global
import os

# External


#External
def GetTarget():
global __target;

return __target;

global __target

return __target


def Append(string):
global __target;

__target.write(string);

global __target

__target.write(string)


def Line(string):
Append(string);
Append("\r\n");

Append(string)
Append("\r\n")


def SetTarget(target):
global __target;

__target = target;
global __target

__target = target


#Internals
__target = open(os.devnull, 'w'); #default to not create a log
# Internals
__target = open(os.devnull, 'w') # default to not create a log
Loading