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
16 changes: 8 additions & 8 deletions Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,19 +742,19 @@ def GetModule(filename):
module_name = os.path.basename(filename).split('.py')[0]

# find and load module
try:
#try:
#name, ext = os.path.splitext(module_name)
#pkg = '.'.join(modulename.split('.')[0:-1])
#module = importlib.import_module(name, package=pkg)

f, fn, description = imp.find_module(module_name, [dir_name])
module = imp.load_module(module_name, f, fn, description)
f.close()
return module
f, fn, description = imp.find_module(module_name, [dir_name])
module = imp.load_module(module_name, f, fn, description)
f.close()
return module

except Exception as info:
sys.stderr.write(_("Module %s not imported from %s!\n"%(module_name,dir_name)))
return sys.exc_info()
#except Exception as info:
# sys.stderr.write(_("Module %s not imported from %s!\n"%(module_name,dir_name)))
# return sys.exc_info()

@staticmethod
def GetBlock(filename, label):
Expand Down
2 changes: 1 addition & 1 deletion LibraryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ def OnItemRefresh(self, evt):
finally:
if self.GetItemImage(item) != 1:

NotificationMessage(_('Information'), _("Model %s has been succeffully updated!")%self.GetItemText(item), self, flag=wx.ICON_ERROR, timeout=5)
NotificationMessage(_('Information'), _("Model %s has been succeffully updated!")%self.GetItemText(item), self, timeout=5)

###
def OnItemEdit(self, evt):
Expand Down
8 changes: 4 additions & 4 deletions SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ def GetClock(self):

###
def MsgBoxEmptyModel(self):
""" Pop-up alert for empty model
""" Pop-up alert for empty model.
"""
dial = wx.MessageDialog(self,
_('You want to simulate an empty master model!'),
_('Simulation Manager'),
wx.OK|wx.ICON_EXCLAMATION)

if (dial.ShowModal() == wx.ID_OK) and (isinstance(self.parent, wx.Frame)):
if (dial.ShowModal() == wx.ID_OK) and isinstance(self.parent, wx.Frame):
self.PrepareDestroyWin()
### destroy the frame
self.Destroy()
Expand All @@ -659,7 +659,7 @@ def SetFields(self):
printOnStatusBar(self.statusbar, {i:'' for i in range(self.statusbar.GetFieldsCount())})

def PrepareDestroyWin(self):
""" To destroy the simulation frame
""" To destroy the simulation frame.
"""

### clean status bar
Expand Down Expand Up @@ -694,7 +694,7 @@ def PrepareDestroyWin(self):
pass

def OnQuit(self, event):
""" When the simulation are stopping
""" When the simulation are stopping.
"""

# if the simulation is running
Expand Down
4 changes: 3 additions & 1 deletion Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,9 +872,11 @@ def listf(data):

def RGBToHEX(rgb_tuple):
""" convert an (R, G, B) tuple to #RRGGBB """
hexcolor = '#%02x%02x%02x' % rgb_tuple

hexcolor = f'#%02x%02x%02x'%rgb_tuple[:-1]
# that's it! '%02x' means zero-padded, 2-digit hex values
return hexcolor


def HEXToRGB(colorstring):
""" convert #RRGGBB to an (R, G, B) tuple """
Expand Down
25 changes: 13 additions & 12 deletions ZipManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def getPythonModelFileName(fn:str)->str:

class Zip:

def __init__(self, fn, files = []):
def __init__(self, fn:str, files:[str]=[]):
""" Constructor
"""
### local copy
Expand All @@ -100,7 +100,7 @@ def __init__(self, fn, files = []):
if files != []:
self.Create(files)

def Create(self, add_files = []):
def Create(self, add_files:[str]=[])->None:
dir_name, base_name = os.path.split(self.fn)
name, ext = os.path.splitext(base_name)

Expand All @@ -126,7 +126,7 @@ def Create(self, add_files = []):

zout.close()

def Update(self, replace_files=[]):
def Update(self, replace_files:[str]=[])->None:
""" Update zip archive with the new replace file names
"""

Expand Down Expand Up @@ -190,7 +190,7 @@ def Update(self, replace_files=[]):
### remove and rename the zip file
self.ClearFiles()

def Delete(self, delete_files=[]):
def Delete(self, delete_files:[str]=[])->None:
""" Remove file in zip archive
"""

Expand Down Expand Up @@ -218,7 +218,7 @@ def Delete(self, delete_files=[]):
### remove and rename the zip file
self.ClearFiles()

def GetImage(self, scaleW=16, scaleH=16):
def GetImage(self, scaleW:int=16, scaleH:int=16):
""" Get image object from image file stored in zip file.
scaleH and scaleW are used to rescale image
"""
Expand Down Expand Up @@ -285,7 +285,7 @@ def HasTests(fn:str)->bool:
return any([re.search("^(BDD/[\w*/]*\.py|BDD/[\w*/]*\.feature)$", s) for s in nl])

@staticmethod
def GetTests(fn):
def GetTests(fn:str)->[str]:
""" Return feature, steps and environment files from .amd
"""
zf = zipfile.ZipFile(fn, 'r')
Expand All @@ -299,7 +299,7 @@ def GetTests(fn):
return tests_files
# ------------------------------------------------------------------------------

def GetModule(self, rcp=False):
def GetModule(self, rcp: bool=False)->types.ModuleType:
""" Return module from zip file corresponding to the amd or cmd model.
It used when the tree library is created.
If the module refered by self.fn is already imported, its returned else its imported using zipimport
Expand All @@ -312,7 +312,7 @@ def GetModule(self, rcp=False):

return self.ImportModule() if self.fullname not in sys.modules else sys.modules[self.fullname]

def ImportModule(self):
def ImportModule(self)->types.ModuleType:
""" Import module from zip file corresponding to the amd or cmd model.
"""
### allows to import the lib from its name (like import MyModel.amd). Dangerous because confuse!
Expand Down Expand Up @@ -366,7 +366,7 @@ def ReImport(self):
return module

@staticmethod
def ClearCache(fn):
def ClearCache(fn:str)->None:
"""Clear out cached entries from _zip_directory_cache"""

if fn in zipimport._zip_directory_cache:
Expand All @@ -375,12 +375,13 @@ def ClearCache(fn):
if fn not in sys.path:
sys.path.append(fn)

def ClearFiles(self):
""" remove and rename the zip file
def ClearFiles(self)->None:
""" remove and rename the zip file.
"""
try:
os.remove(self.fn)
except info:
except Exception as info:
#sys.exc_info()
sys.stderr.write(_('File has not been deleted: %s'%info))

try:
Expand Down