def add_alias(database: Database, name: str, command_from: str, command_to: str) -> Alias: new_alias = Alias({ 'name': name, 'command_from': command_from, 'command_to': command_to }) database.aliases.append(new_alias) database.save() return new_alias
def get_alias_packs() -> Dict[str, List[Alias]]: data = requests.get(const.ALIASES_REST).json() packs = {} for key in data.keys(): packs.update({key: [Alias(dict_alias) for dict_alias in data[key]]}) return packs
def aliases(data: dict) -> List[Alias]: try: return [Alias(alias) for alias in data['aliases']] except KeyError: return []