mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
stringify: introduce _class_suffixes for easy jsonize
class variable '_class_suffixes' can be used for the same purpose as '_class_prefixes' but match with the suffix of the class name. Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
7a5b83daa6
commit
fc2b0b0f9c
@ -105,6 +105,7 @@ class StringifyMixin(object):
|
||||
"""
|
||||
|
||||
_class_prefixes = []
|
||||
_class_suffixes = []
|
||||
|
||||
def stringify_attrs(self):
|
||||
"""an override point for sub classes"""
|
||||
@ -133,6 +134,9 @@ class StringifyMixin(object):
|
||||
for p in cls._class_prefixes:
|
||||
if k.startswith(p):
|
||||
return True
|
||||
for p in cls._class_suffixes:
|
||||
if k.endswith(p):
|
||||
return True
|
||||
return False
|
||||
|
||||
@classmethod
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user