Skip to content

Commit fbde16d

Browse files
committed
bug fix
1 parent 41160e0 commit fbde16d

3 files changed

Lines changed: 30 additions & 24 deletions

File tree

devsimpy/config.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import os, sys
1+
import os
2+
import sys
23
import builtins
34

4-
##########################################################
5-
### PATHS defined from the current dir used to execute devsimpy
6-
##########################################################
5+
""" PATHS defined from the current dir used to execute devsimpy
6+
"""
77
ABS_HOME_PATH = os.path.abspath(os.path.dirname(__file__))
88
DEVS_SIM_KERNEL_PATH = os.path.join(ABS_HOME_PATH, 'DEVSKernel')
99

1010
builtins.ABS_HOME_PATH = ABS_HOME_PATH
1111
builtins.DEVS_SIM_KERNEL_PATH = DEVS_SIM_KERNEL_PATH
1212

13-
##########################################################
14-
### GLOBAL_SETTINGS for handle the paths of the DEVSimPy package
15-
##########################################################
13+
""" GLOBAL_SETTINGS for handle the paths of the DEVSimPy package
14+
"""
1615

1716
GLOBAL_SETTINGS = {
1817
'SPLASH_PNG': os.path.join(ABS_HOME_PATH, 'splash', 'splash.png'),
@@ -33,11 +32,12 @@
3332
'GUI_FLAG': True
3433
}
3534

36-
##########################################################
37-
### USER_SETTINGS for handle the user preferences
38-
##########################################################
39-
40-
# specific built-in variables. (don't modify the default value. If you want to change it, go to the PreferencesGUI from devsimpy interface.)
35+
""" USER_SETTINGS for handle the user preferences
36+
"""
37+
# Specific built-in variables.
38+
# (don't modify the default value.
39+
# If you want to change it,
40+
# go to the PreferencesGUI from devsimpy interface.)
4141
USER_SETTINGS = {
4242
'SIMULATION_SUCCESS_SOUND_PATH': os.path.join('sounds', 'Simulation-Success.wav'),
4343
'SIMULATION_ERROR_SOUND_PATH': os.path.join('sounds', 'Simulation-Error.wav'),
@@ -66,22 +66,27 @@
6666
'DEFAULT_PLOT_DYN_FREQ': 100
6767
}
6868

69-
### Check if the pypdevs241 directory is empty (not --recursive option when the devsimpy git has been cloned)
69+
# Check if the pypdevs241 directory is empty
70+
# (not --recursive option when the devsimpy git has been cloned)
7071
path = os.path.join(DEVS_SIM_KERNEL_PATH, 'PyPDEVS', 'pypdevs241')
7172
if os.path.exists(path) and not len(os.listdir(path)) == 0:
7273
GLOBAL_SETTINGS['PYPDEVS_241_SIM_STRATEGY_DICT'] = {'classic': 'SimStrategy4', 'parallel': 'SimStrategy5'}
7374
GLOBAL_SETTINGS['DEVS_DIR_PATH_DICT'].update({'PyPDEVS_241': os.path.join(path, 'src', 'pypdevs')})
7475
else:
7576
sys.stdout.write("PyPDEVS Kernel in version 2.4.1 is not loaded.\nPlease install it in the directory %s using git (https://github.com/kdheepak/pypdevs.git)\n"%path)
7677

77-
### All SETTINGS
78+
# All SETTINGS
7879
ALL_SETTINGS = GLOBAL_SETTINGS | USER_SETTINGS
7980

80-
###########################################
81-
### Define functions
82-
###########################################
81+
""" Define functions
82+
"""
8383

8484
def UpdateBuiltins(new_settings=ALL_SETTINGS):
85-
# Met à jour les variables globales de `builtins`
85+
"""Update builtins with new settings.
86+
"""
87+
# Check if the new settings are valid
88+
if not isinstance(new_settings, dict):
89+
raise ValueError("new_settings must be a dictionary")
90+
8691
for key, value in new_settings.items():
8792
setattr(builtins, key, value)

tests/test_wizardgui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from ApplicationController import TestApp
1111

12-
# import after ApplicationController that inits sys.path ot avoid this import
12+
# Import after ApplicationController that inits sys.path ot avoid this import
1313
from WizardGUI import ModelGeneratorWizard
1414

1515
# Run the test

tests/test_xmlmodule.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
python test_xmlmodule.py --autoclose 10 # Auto-close after 10s delay
66
"""
77

8-
import wx, os
8+
import wx
9+
import os
910

1011
from ApplicationController import TestApp
1112

@@ -18,14 +19,14 @@
1819
app = TestApp(0)
1920

2021
diagram = Container.Diagram()
21-
22+
2223
frame = DetachedFrame.DetachedFrame(None, -1, "Test", diagram)
2324
newPage = Container.ShapeCanvas(frame, wx.NewIdRef(), name='Test')
2425
newPage.SetDiagram(diagram)
2526

26-
path = os.path.join(os.path.expanduser("~"),'Downloads','Watershed.xml')
27-
#path = os.path.join(os.path.expanduser("~"),'Downloads','example.xmlsestree')
27+
path = os.path.join(os.path.expanduser("~"), 'Downloads', 'Watershed.xml')
28+
# path = os.path.join(os.path.expanduser("~"),'Downloads','example.xmlsestree')
2829
getDiagramFromXMLSES(path, canvas=newPage)
29-
#diagram.SetParent(newPage)
30+
# diagram.SetParent(newPage)
3031

3132
app.RunTest(frame)

0 commit comments

Comments
 (0)