mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-12 08:56:13 +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:
parent
1c412c14ee
commit
c78da6c496
@ -7991,12 +7991,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
# restore the old exec semantic
|
# restore the old exec semantic
|
||||||
mod.__dict__.update(globals())
|
mod.__dict__.update(globals())
|
||||||
for name in dir(mod):
|
for name in dir(mod):
|
||||||
func = getattr(mod, name)
|
data = getattr(mod, name)
|
||||||
# add all functions (which are defined in the imported module)
|
# Add all functions (which are defined in the imported module)
|
||||||
# to the class (filtering only methods which start with "do_"
|
# to the class (filtering only methods which start with "do_"
|
||||||
# breaks the old behavior)
|
# breaks the old behavior).
|
||||||
if inspect.isfunction(func) and inspect.getmodule(func) == mod:
|
# Also add imported modules (needed for backward compatibility).
|
||||||
setattr(self.__class__, name, func)
|
# 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:
|
except SyntaxError as e:
|
||||||
if (os.environ.get('OSC_PLUGIN_FAIL_IGNORE')):
|
if (os.environ.get('OSC_PLUGIN_FAIL_IGNORE')):
|
||||||
print("%s: %s\n" % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)
|
print("%s: %s\n" % (os.path.join(plugin_dir, extfile), e), file=sys.stderr)
|
||||||
|
Loading…
Reference in New Issue
Block a user