mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-05 20:36:10 +02:00
of_config: allows both of of-config element names and python style names
for convenience of api consumers, allows both of of-config style element names (eg. logical-switches) and python style attribute names (eg. logical_switches). Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
f3060bff7d
commit
ac94864869
@ -60,11 +60,16 @@ class _Base(stringify.StringifyMixin):
|
||||
k = _pythonify(e.name)
|
||||
try:
|
||||
v = kwargs.pop(k)
|
||||
assert not e.name in kwargs
|
||||
except KeyError:
|
||||
if e.is_list:
|
||||
v = []
|
||||
else:
|
||||
v = None
|
||||
k = e.name
|
||||
try:
|
||||
v = kwargs.pop(k)
|
||||
except KeyError:
|
||||
if e.is_list:
|
||||
v = []
|
||||
else:
|
||||
v = None
|
||||
setattr(self, k, v)
|
||||
if kwargs:
|
||||
raise TypeError('unknown kwargs %s' % kwargs)
|
||||
@ -129,6 +134,12 @@ class _Base(stringify.StringifyMixin):
|
||||
kwargs[k] = v
|
||||
return cls(**kwargs)
|
||||
|
||||
def __getattribute__(self, k):
|
||||
return stringify.StringifyMixin.__getattribute__(self, _pythonify(k))
|
||||
|
||||
def __setattr__(self, k, v):
|
||||
stringify.StringifyMixin.__setattr__(self, _pythonify(k), v)
|
||||
|
||||
|
||||
class _Unimpl(_Base):
|
||||
_ELEMENTS = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user