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 <[email protected]> --- ryu/lib/of_config/base.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ryu/lib/of_config/base.py b/ryu/lib/of_config/base.py index bb467f7..6495924 100644 --- a/ryu/lib/of_config/base.py +++ b/ryu/lib/of_config/base.py @@ -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 = [ -- 1.8.3.1 ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
