def gen_avatar_path(puid, force=False): need_update = True avatar_url = avatar_tmpl.format(puid) avatar_path = os.path.join(here, '../{}'.format(avatar_url)) if os.path.exists(avatar_path): mtime = datetime.fromtimestamp(os.stat(avatar_path).st_mtime) if datetime.now() - mtime < timedelta(days=1) and not force: need_update = False return avatar_url, avatar_path, need_update
def avatar(self): return avatar_tmpl.format(self.id)