added shit

This commit is contained in:
2022-04-16 02:40:01 +03:00
parent cb43e8f2c0
commit c5c978ed52
+15 -2
View File
@@ -36,6 +36,21 @@ class Meme:
return random.choice(attachments.get('video'))
def dump_meta(self, path: str = None):
if not path:
path = "current_meta.json"
with open(path, 'w', encoding='utf8') as f:
f.write(json.dumps(self.meta))
@staticmethod
def info_from_json(path: str) -> str:
with open(path, 'w', encoding='utf8') as f:
data = json.loads(f.read())
return f"{'Fandom: ' if data.get('fandom') else 'Project: '} {data.get('fandom', data.get('Project'))}\n"\
f"Character(s):\n{', '.join(c for c in data.get('characters'))}\n"
@staticmethod
def flatten_meta(meta: dict[str, any]) -> list[str]:
return [a for k in [i for i in meta.values()] for a in k]
@@ -65,8 +80,6 @@ class DayOfTheWeek:
else:
return self.days[day]
@staticmethod
def get_data() -> list[Day]:
folder = os.path.dirname(os.path.abspath(__file__))