Add documentation

This commit is contained in:
moanos [he/him] 2023-01-12 07:46:11 +01:00
parent 7c54a1286a
commit 45f52b940e

View File

@ -57,6 +57,7 @@ class Instance:
pass
def apply(self, server, token, block_id=None):
"""Applies instance block on the remote server"""
headers = {
f'Authorization': f'Bearer {token}',
}
@ -77,6 +78,7 @@ class Instance:
raise ConnectionError(f"Could not apply block ({response.status_code}: {response.reason})")
def delete(self, server: str, token: str):
"""Deletes the instance from the blocklist on the remote server"""
headers = {
f'Authorization': f'Bearer {token}',
}
@ -86,6 +88,7 @@ class Instance:
@staticmethod
def list_diffs(local_blocklist, remote_blocklist):
"""Compares the local and remote blocklist and returns a list of differences"""
diffs = []
for local_instance in local_blocklist:
instance_found = False
@ -109,6 +112,7 @@ class Instance:
@staticmethod
def apply_blocks_from_diff(diffs, server, token, no_delete: bool):
"""Uses a diff (list of difference in local an remote instance) to apply instance blocks"""
for diff in diffs:
if diff["local"] is None:
if not no_delete:
@ -126,6 +130,7 @@ class Instance:
@staticmethod
def show_diffs(local_blocklist, remote_blocklist):
"""Shows a table in the CLI comparing the local and remote blocklist"""
from rich.table import Table
from rich.console import Console
table = Table(title="Differences", expand=True, show_lines=True)