Commit bf391e07 by Őry Máté

common: add HumanReadableObject.set()

parent 3f60bd73
...@@ -353,6 +353,9 @@ except ImportError: ...@@ -353,6 +353,9 @@ except ImportError:
class HumanReadableObject(object): class HumanReadableObject(object):
def __init__(self, user_text_template, admin_text_template, params): def __init__(self, user_text_template, admin_text_template, params):
self._set_values(user_text_template, admin_text_template, params)
def _set_values(self, user_text_template, admin_text_template, params):
self.user_text_template = user_text_template self.user_text_template = user_text_template
self.admin_text_template = admin_text_template self.admin_text_template = admin_text_template
self.params = params self.params = params
...@@ -362,6 +365,10 @@ class HumanReadableObject(object): ...@@ -362,6 +365,10 @@ class HumanReadableObject(object):
return cls(user_text_template, return cls(user_text_template,
admin_text_template or user_text_template, params) admin_text_template or user_text_template, params)
def set(self, user_text_template, admin_text_template=None, **params):
self._set_values(user_text_template,
admin_text_template or user_text_template, params)
@classmethod @classmethod
def from_dict(cls, d): def from_dict(cls, d):
return None if d is None else cls(**d) return None if d is None else cls(**d)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment