@@ -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 :
0 commit comments