Change in vdsm[master]: tool: autoload modules.
smizrahi at redhat.com
smizrahi at redhat.com
Sun Nov 9 13:54:53 UTC 2014
Saggi Mizrahi has posted comments on this change.
Change subject: tool: autoload modules.
......................................................................
Patch Set 3:
(2 comments)
http://gerrit.ovirt.org/#/c/34049/3/lib/vdsm/tool/configurator.py
File lib/vdsm/tool/configurator.py:
Line 84: def _import_module(abspkg, mname):
Line 85: """return imported module mname from abspkg."""
Line 86: # remove this function and use importlib once python version >= 2.7
Line 87: pkg = "%s.%s" % (abspkg.__name__, mname)
Line 88: __import__(pkg, level=0)
comment on why you are not just returning the result of __import__
Line 89: return sys.modules[pkg]
Line 90:
Line 91:
Line 92: def _listmodules(pkg):
Line 100: for module in glob("%s*.py" % path)
Line 101: if filter_(getmname(module))
Line 102: ]
Line 103:
Line 104: _CONFIGURATORS = {}
I'd prefer if this was lazy loaded since it's a lot of work to do during import.
Line 105: for module in _listmodules(configurators):
Line 106: _CONFIGURATORS[module] = _import_module(configurators, module)
Line 107:
Line 108:
--
To view, visit http://gerrit.ovirt.org/34049
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I6cc14a1c409ee607e18d42adcd8a54759d8dbf6d
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mtayer at redhat.com>
Gerrit-Reviewer: Alon Bar-Lev <alonbl at redhat.com>
Gerrit-Reviewer: Dima Kuznetsov <dkuznets at redhat.com>
Gerrit-Reviewer: Ohad Basan <obasan at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: Yeela Kaplan <ykaplan at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: mooli tayer <mtayer at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list