Started refactoring to py-gitea
This commit is contained in:
36
domain/API.py
Normal file
36
domain/API.py
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
import gitea
|
||||
|
||||
|
||||
class API:
|
||||
|
||||
__DEFAULT_API_PATH = "/api/v1"
|
||||
|
||||
def __init__(self):
|
||||
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _make_api_base_url(hostname, port):
|
||||
|
||||
base = f"https://{hostname}"
|
||||
if port is not None:
|
||||
base += f":{port}"
|
||||
|
||||
return base
|
||||
|
||||
@staticmethod
|
||||
def factory(hostname, port, token) -> gitea.Gitea:
|
||||
|
||||
url = API._make_api_base_url(
|
||||
hostname=hostname,
|
||||
port=port
|
||||
)
|
||||
|
||||
g = gitea.Gitea(
|
||||
gitea_url=url,
|
||||
token_text=token
|
||||
)
|
||||
|
||||
return g
|
||||
Reference in New Issue
Block a user