0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-09 10:31:53 +00:00
bird/python/BIRD/Basic.py
Maria Matejka 04f96b6705 Python CLI Package: Protocol scaffolding for Kernel, Device, Direct, Babel and RAdv
This choice comes from my own local setup where I use exactly these protocols.
Other protocols will be added later.
2023-05-23 13:44:48 +02:00

35 lines
738 B
Python

import asyncio
class BIRDException(Exception):
pass
class Basic:
def __init__(self, bird):
self.bird = bird
self.data = None
def __getattr__(self, name):
if self.data is None:
raise BIRDException(f"Call update() to get data")
if name not in self.data:
raise BIRDException(f"Unknown key {name} in {type(self)}")
return self.data[name]
def __repr__(self):
return f"{type(self).__name__}({self.data})"
async def load(self):
if self.data is None:
await self.update()
class Code:
OK = 0
Welcome = 1
Status = 13
Version = 1000
ProtocolInfo = 1002
ProtocolDetails = 1006
ProtocolListHeader = 2002