Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
macro_lib = None
params = dict(module=m, name=module_name,
macro_server=self.macro_server, exc_info=exc_info)
if m is None:
file_name = self._findMacroLibName(module_name)
if file_name is None:
if exc_info:
msg = format_exception_only_str(*exc_info[:2])
else:
msg = "Error (re)loading macro library '%s'" % module_name
raise LibraryError(msg, exc_info=exc_info)
params['file_path'] = file_name
macro_lib = MacroLibrary(**params)
else:
macro_lib = MacroLibrary(**params)
abs_file = macro_lib.file_path
_is_macro = functools.partial(is_macro, abs_file=abs_file,
logger=self)
for _, macro in inspect.getmembers(m, _is_macro):
try:
self.addMacro(macro_lib, macro)
except:
self.error("Error adding macro %s", macro.__name__)
self.debug("Details:", exc_info=1)
self._modules[module_name] = macro_lib
return macro_lib
:raises:
LibraryError in case the reload process is not successful
:param module_name: macro library name (=python module name)
:param path:
a list of absolute path to search for libraries [default: None,
means the current MacroPath will be used]
:return: the MacroLibrary object for the reloaded macro library"""
path = path or self.getMacroPath()
mod_manager = ModuleManager()
m, exc_info = None, None
valid, exc_info = mod_manager.isValidModule(module_name, path)
if not valid:
params = dict(module=m, name=module_name,
macro_server=self.macro_server, exc_info=exc_info)
return MacroLibrary(**params)
# if there was previous Macro Library info remove it
old_macro_lib = self._modules.pop(module_name, None)
if old_macro_lib is not None:
for macro in old_macro_lib.get_macros():
self._macro_dict.pop(macro.name)
try:
m = mod_manager.reloadModule(module_name, path)
except:
exc_info = sys.exc_info()
macro_lib = None
params = dict(module=m, name=module_name,
macro_server=self.macro_server, exc_info=exc_info)
except:
exc_info = sys.exc_info()
macro_lib = None
params = dict(module=m, name=module_name,
macro_server=self.macro_server, exc_info=exc_info)
if m is None:
file_name = self._findMacroLibName(module_name)
if file_name is None:
if exc_info:
msg = format_exception_only_str(*exc_info[:2])
else:
msg = "Error (re)loading macro library '%s'" % module_name
raise LibraryError(msg, exc_info=exc_info)
params['file_path'] = file_name
macro_lib = MacroLibrary(**params)
else:
macro_lib = MacroLibrary(**params)
abs_file = macro_lib.file_path
_is_macro = functools.partial(is_macro, abs_file=abs_file,
logger=self)
for _, macro in inspect.getmembers(m, _is_macro):
try:
self.addMacro(macro_lib, macro)
except:
self.error("Error adding macro %s", macro.__name__)
self.debug("Details:", exc_info=1)
self._modules[module_name] = macro_lib
return macro_lib
macro_errors = {}
count_correct_macros = 0
count_incorrect_macros = 0
if m is None:
file_name = self._findMacroLibName(module_name)
if file_name is None:
if exc_info:
msg = format_exception_only_str(*exc_info[:2])
else:
msg = "Error (re)loading macro library '%s'" % module_name
raise LibraryError(msg, exc_info=exc_info)
params['file_path'] = file_name
macro_lib = MacroLibrary(**params)
else:
macro_lib = MacroLibrary(**params)
abs_file = macro_lib.file_path
_is_macro = functools.partial(is_macro, abs_file=abs_file,
logger=self)
for _, macro in inspect.getmembers(m, _is_macro):
try:
isoverwritten = False
macro_name = macro.__name__
if macro_name in self._overwritten_macros:
isoverwritten = True
elif (macro_name in list(self._macro_dict.keys())
and self._macro_dict[macro_name].lib != macro_lib):
isoverwritten = True
msg = ('Macro "{}" defined in "{}" macro library'
+ ' has been overwritten by "{}" macro library')
old_lib_name = self._macro_dict[macro_name].lib.name
self.debug(msg.format(macro_name, old_lib_name,
# Dictionary for gathering macros with errors
macro_errors = {}
count_correct_macros = 0
count_incorrect_macros = 0
if m is None:
file_name = self._findMacroLibName(module_name)
if file_name is None:
if exc_info:
msg = format_exception_only_str(*exc_info[:2])
else:
msg = "Error (re)loading macro library '%s'" % module_name
raise LibraryError(msg, exc_info=exc_info)
params['file_path'] = file_name
macro_lib = MacroLibrary(**params)
else:
macro_lib = MacroLibrary(**params)
abs_file = macro_lib.file_path
_is_macro = functools.partial(is_macro, abs_file=abs_file,
logger=self)
for _, macro in inspect.getmembers(m, _is_macro):
try:
isoverwritten = False
macro_name = macro.__name__
if macro_name in self._overwritten_macros:
isoverwritten = True
elif (macro_name in list(self._macro_dict.keys())
and self._macro_dict[macro_name].lib != macro_lib):
isoverwritten = True
msg = ('Macro "{}" defined in "{}" macro library'
+ ' has been overwritten by "{}" macro library')