current_plugins_manager=None
def initialize(module,name,basemenuname,menuname):
- if not plugins.has_key(name):
+ if name not in plugins:
if module:
plugins[name]={}
else:
plugins[name]=[]
if module:
d=sgPyQt.getDesktop()
- if plugins[name].has_key(d):return
+ if d in plugins[name]:return
plugins[name][d]=PluginsManager(module,name,basemenuname,menuname)
else:
plugins[name].append(PluginsManager(module,name,basemenuname,menuname))
class PluginsManager:
def __init__(self,module,name,basemenuname,menuname):
self.name=name
- self.basemenuname=unicode(basemenuname, "utf-8")
- self.menuname=unicode(menuname, "utf-8")
+ self.basemenuname=basemenuname
+ self.menuname=menuname
self.module=module
self.registry={}
self.handlers={}
# MODULES plugins are supposed to be located in the
# installation folder of the module, in the subdirectory
# "share/salome/plugins". We first look for these directories.
+ searched = []
for key in os.environ.keys():
if key.endswith("_ROOT_DIR"):
rootpath=os.environ[key]
dirpath=os.path.join(rootpath,PLUGIN_PATH_PATTERN)
- if os.path.isdir(dirpath) and dirpath not in self.plugindirs:
+ if os.path.isdir(dirpath) and dirpath not in self.plugindirs + searched:
logger.debug("Looking for plugins in the directory %s ..."%dirpath)
walktree(dirpath,self.analyseFile)
+ if dirpath not in self.plugindirs and dirpath not in searched:
+ searched.append(dirpath)
# USER plugins directory
user_dir = os.path.expanduser("~/.config/salome/Plugins")
sys.path.insert(0,directory)
logger.debug("The directory %s has been added to PYTHONPATH"%directory)
try:
- execfile(plugins_file,globals(),{})
+ exec(compile(open(plugins_file).read(), plugins_file, 'exec'),globals(),{})
except:
logger.fatal("Error while loading plugins from file %s"%plugins_file)
traceback.print_exc()
submenus[str(menu.title())]=menu
while len(names) > 1:
name=names.pop(0)
- if submenus.has_key(name):
+ if name in submenus:
amenu=submenus[name]
else:
amenu=QMenu(name,parentMenu)