# HG changeset patch # User Goffi # Date 1587329535 -7200 # Node ID a9e8e925ad99639c867ac95795036a6b2def9a55 # Parent e9ecd133773b772ac5502ba24002e8cecdec9881 tools (common/data_objects): new `avatar_basename` property diff -r e9ecd133773b -r a9e8e925ad99 sat/tools/common/data_objects.py --- 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]