Skip to content

Commit a4c7ac8

Browse files
authored
Merge pull request #180 from capocchi/version-4.0
bug fix
2 parents ee48016 + 02293ba commit a4c7ac8

4 files changed

Lines changed: 30 additions & 16 deletions

File tree

Components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ def GetModule(filename):
909909

910910
### try to import module
911911
try:
912-
module = spec.loader.load_module()
912+
module = spec.loader.load_module(module_name)
913913
except (ValueError, ImportError) as msg:
914914
sys.stderr.write(_("Module %s not imported from %s: %s!\n"%(module_name,dir_name,str(msg))))
915915
module = sys.exc_info()

Container.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3072,10 +3072,14 @@ def GetTestFile(self):
30723072

30733073
# NOTE: Testable :: isAMD => Test if the model is an AMD and if it's well-formed
30743074
def isAMD(self):
3075-
return zipfile.is_zipfile(os.path.dirname(self.python_path))
3075+
fn = os.path.dirname(self.python_path)
3076+
return zipfile.is_zipfile(fn) or fn.endswith(('.amd','.cmd')) if os.path.isfile(fn) else False
30763077

30773078
def isPYC(self):
3078-
return self.python_path.endswith('.pyc')
3079+
return self.python_path.endswith('.pyc') if os.path.isfile(self.python_path) else False
3080+
3081+
def isPY(self):
3082+
return self.python_path.endswith('.py') if os.path.isfile(self.python_path) else False
30793083

30803084
# NOTE: Testable :: CreateTestsFiles => AMD tests files creation
30813085
def CreateTestsFiles(self):
@@ -3763,14 +3767,22 @@ def __setstate__(self, state):
37633767

37643768
### for .cmd or .amd
37653769
else:
3766-
pass
3767-
#with zipfile.ZipFile(model_path) as zf:
3768-
# ### find all python files
3769-
# for file in zf.namelist():
3770-
# r = repr(zf.read(file))
3771-
# if file.endswith(".py") and ('DomainBehavior' in r or 'DomainStructure' in r):
3772-
# #state['python_path'] = os.path.join(model_path, os.path.basename(model_path).replace('.amd','.py').replace('.cmd','.py'))
3773-
# state['bad_filename_path_flag'] = file != state['python_path']
3770+
if not os.path.exists(model_path) :
3771+
state['bad_filename_path_flag'] = True
3772+
# else:
3773+
# with zipfile.ZipFile(model_path) as zf:
3774+
# ### find all python files
3775+
# for file in zf.namelist():
3776+
# path = os.path.join(model_path, os.path.basename(model_path).replace('.amd','.py').replace('.cmd','.py'))
3777+
# #cls = GetClass(path)
3778+
# if file.endswith(".py"):# and (issubclass(cls, DomainBehavior) or issubclass(cls, DomainStructure)):
3779+
# if os.path.exists(model_path):
3780+
# state['python_path'] = path
3781+
# else:
3782+
# state['bad_filename_path_flag'] = True
3783+
#state['python_path'] = os.path.join(model_path, os.path.basename(model_path).replace('.amd','.py').replace('.cmd','.py'))
3784+
#state['bad_filename_path_flag'] = file != state['python_path']
3785+
37743786

37753787
### if the fileName attribut dont exist, we define it into the current devsimpy directory (then the user can change it from Property panel)
37763788
if 'args' in state:

Menu.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,12 @@ def __init__(self, shape, event):
10181018
else:
10191019

10201020
if isinstance(shape, Container.CodeBlock) and shape.isAMD():
1021-
Edit_menu = AppendMenu(self, -1, _("Edit"), edit_subMenu)
1022-
Edit_SubMenu1 = edit_subMenu.AppendItem(editModel)
1023-
Edit_SubMenu2 = edit_subMenu.AppendItem(editTest)
1021+
Edit_menu = AppendMenu(self, -1, _("Edit"), edit_subMenu)
1022+
Edit_SubMenu1 = edit_subMenu.AppendItem(editModel)
1023+
Edit_SubMenu2 = edit_subMenu.AppendItem(editTest)
10241024
else:
10251025
Edit_menu = AppendItem(edit)
1026-
1026+
10271027
if isinstance(shape, Container.CodeBlock) and shape.isPYC():
10281028
Edit_menu.Enable(False)
10291029

@@ -1147,8 +1147,10 @@ def __init__(self, shape, event):
11471147
# AMD specific binding
11481148
if shape.isAMD():
11491149
self.__canvas.Bind(wx.EVT_MENU, shape.OnTestEditor, id=ID_TESTING_SHAPE)
1150-
else:
1150+
elif shape.isPY():
11511151
self.__canvas.Bind(wx.EVT_MENU, shape.OnEditor, id=ID_EDIT_SHAPE)
1152+
else:
1153+
self.Enable(ID_EDIT_SHAPE, False)
11521154

11531155
# ContainerBlock specific binding
11541156
elif isinstance(shape, Container.ContainerBlock):

new_arch.zip

10.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)