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:
ISHIDA Wataru 2014-08-18 09:19:07 +09:00 committed by FUJITA Tomonori
parent 7a5b83daa6
commit fc2b0b0f9c

View File

@ -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