Mercurial > libervia-backend
changeset 3261:a9e8e925ad99
tools (common/data_objects): new `avatar_basename` property
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 19 Apr 2020 22:52:15 +0200 (2020-04-19) |
parents | e9ecd133773b |
children | aa71f1d40300 |
files | sat/tools/common/data_objects.py |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/sat/tools/common/data_objects.py Sun Apr 19 16:54:13 2020 +0200 +++ b/sat/tools/common/data_objects.py Sun Apr 19 22:52:15 2020 +0200 @@ -21,6 +21,7 @@ from sat.core.constants import Const as C from sat.tools.common import data_format +from os.path import basename try: from jinja2 import Markup as safe @@ -361,6 +362,13 @@ self.jid_str = jid_str self.data = data if data is not None else {} + @property + def avatar_basename(self): + try: + return basename(self.data['avatar']['path']) + except (TypeError, KeyError): + return None + def __getitem__(self, key): return self.data[key]