mirror of
https://github.com/samba-team/samba.git
synced 2025-12-16 00:23:52 +03:00
netcmd: support hyphens in top-level commands and convert to underscore
Hyphens in python modules are invalid and makes them only importable by importlib, which makes them harder to import in tests. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
This commit is contained in:
committed by
Andrew Bartlett
parent
2a95f83c5c
commit
de8b61cbbe
@@ -31,10 +31,11 @@ class cache_loader(dict):
|
||||
def __getitem__(self, attr):
|
||||
item = dict.__getitem__(self, attr)
|
||||
if item is None:
|
||||
cmd = 'cmd_%s' % attr.replace('-', '_')
|
||||
package = 'nettime' if attr == 'time' else attr
|
||||
package = package.replace('-', '_')
|
||||
self[attr] = getattr(__import__('samba.netcmd.%s' % package,
|
||||
fromlist=['cmd_%s' % attr]),
|
||||
'cmd_%s' % attr)()
|
||||
fromlist=[cmd]), cmd)()
|
||||
return dict.__getitem__(self, attr)
|
||||
|
||||
def get(self, attr, default=None):
|
||||
|
||||
Reference in New Issue
Block a user