Skip to content
Merged
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
26 changes: 26 additions & 0 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,38 @@ def setBlock(self, devs):

DEVSComponent.setBlockModel(devs, self)

###
def setDEVSClassModel(self, classe):
""" Set the __class__ attribut of the devs model
@param classe: new classe object
"""
if inspect.isclass(classe):
self.devsModel.__class__ = classe

###
def isCMD(self):
""" Return True if the python file is embedded in CMD file
"""
fn = os.path.dirname(self.getDEVSPythonPath())
return zipfile.is_zipfile(fn) and fn.endswith(('.cmd')) if os.path.isfile(fn) else False

###
def isAMD(self):
""" Return True if the python file is embedded in AMD file
"""
fn = os.path.dirname(self.getDEVSPythonPath())
return zipfile.is_zipfile(fn) and fn.endswith(('.amd')) if os.path.isfile(fn) else False

def isPYC(self):
""" Return True if the python path point to a python file
"""
return self.python_path.endswith('.pyc') if os.path.isfile(self.python_path) else False

def isPY(self):
""" Return True if the python path point to a compiled python file
"""
return self.python_path.endswith('.py') if os.path.isfile(self.python_path) else False

###
def OnLog(self, event):
""" Shows informations inserted with debugger instructions into the model.
Expand Down Expand Up @@ -810,6 +835,7 @@ def OnEditor(self, event):
# loading file in DEVSimPy editor windows (self.text)
try:


editorFrame = Editor.GetEditor(None, wx.NewIdRef(), ''.join([name,' - ',model_path]), obj=self, file_type='block')

# if zipfile.is_zipfile(model_path):
Expand Down
6 changes: 5 additions & 1 deletion Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -3046,7 +3046,11 @@ def GetTestFile(self):
# NOTE: Testable :: isAMD => Test if the model is an AMD and if it's well-formed
def isAMD(self):
fn = os.path.dirname(self.python_path)
return zipfile.is_zipfile(fn) or fn.endswith(('.amd','.cmd')) if os.path.isfile(fn) else False
return zipfile.is_zipfile(fn) and fn.endswith(('.amd')) if os.path.isfile(fn) else False

def isCMD(self):
fn = os.path.dirname(self.python_path)
return zipfile.is_zipfile(fn) and fn.endswith(('.cmd')) if os.path.isfile(fn) else False

def isPYC(self):
return self.python_path.endswith('.pyc') if os.path.isfile(self.python_path) else False
Expand Down
Loading