40 lines
886 B
Python
40 lines
886 B
Python
__author__ = 'RemiZOffAlex'
|
|
__email__ = 'remizoffalex@mail.ru'
|
|
|
|
import base64
|
|
import requests
|
|
|
|
|
|
class Client:
|
|
def __init__(self, url: str, headers: dict = {}, **kwargs):
|
|
self.url = url
|
|
self.headers = headers
|
|
self.kwargs = kwargs
|
|
|
|
def __call__(self, *args, **kwargs):
|
|
self.kwargs
|
|
return self
|
|
|
|
def get(self, *args, **params):
|
|
url = self.url
|
|
if 'node' in self.kwargs:
|
|
url += f'/{self.kwargs['node']}'
|
|
response = requests.get(
|
|
self.url,
|
|
headers=self.headers
|
|
)
|
|
return response.json()
|
|
|
|
|
|
class Octokit:
|
|
def __init__(self, url: str, headers: dict = {}):
|
|
self.url = url
|
|
self.headers = headers
|
|
|
|
def __getattr__(self, key):
|
|
return Client(
|
|
url=self.url,
|
|
headers=self.headers,
|
|
**{'node': key}
|
|
)
|