1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-24 00:56:15 +01:00

- _load_plugins: also add imported modules to the class

This is needed for backward compatibility. New plugins
(which do not care about "old" osc versions) should not
use "self.<imported modname>.<something>" anymore
to refer to the imported module. Instead use
"<imported modname>.<something>" (this will only work with
osc > 0.140.1).
This commit is contained in:
Marcus Huewe 2013-08-15 17:26:07 +02:00
parent 1c412c14ee
commit c78da6c496

View File

@ -7991,12 +7991,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
# restore the old exec semantic
mod.__dict__.update(globals())
for name in dir(mod):
func = getattr(mod, name)
# add all functions (which are defined in the imported module)
data = getattr(mod, name)
# Add all functions (which are defined in the imported module)
# to the class (filtering only methods which start with "do_"
# breaks the old behavior)
if inspect.isfunction(func) and inspect.getmodule(func) == mod:
setattr(self.__class__, name, func)
# breaks the old behavior).
# Also add imported modules (needed for backward compatibility).
# New plugins should not use "self.<imported modname>.<something>"
# to refer to the imported module. Instead use
# "<imported modname>.<something>".
if (inspect.isfunction(data) and inspect.getmodule(data) == mod
or inspect.ismodule(data)):
setattr(self.__class__, name, data)
except SyntaxError as e:
if (os.environ.get('OSC_PLUGIN_FAIL_IGNORE')):
print("%s: %s\n" % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)