Пример #1
0
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
Пример #2
0
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
Пример #3
0
 def aliases(data: dict) -> List[Alias]:
     try:
         return [Alias(alias) for alias in data['aliases']]
     except KeyError:
         return []