format all code

This commit is contained in:
mcbloch 2024-03-27 18:02:53 +01:00
parent f2c1692f5a
commit cf933684f3
6 changed files with 17 additions and 14 deletions

View file

@ -12,7 +12,7 @@ def find_metadata(filename):
metadata = {} metadata = {}
start_strings = [ ":::spoiler Gitlab sync\n" , ":::spoiler git drive sync\n" ] start_strings = [":::spoiler Gitlab sync\n", ":::spoiler git drive sync\n"]
end_str = "\n:::" end_str = "\n:::"
for start_str in start_strings: for start_str in start_strings:
@ -34,5 +34,3 @@ def find_metadata(filename):
print("Not a valid report") print("Not a valid report")
return None return None

View file

@ -56,7 +56,6 @@ users: {str: [User]} = {}
def loadusers(): def loadusers():
usr = None usr = None
for name, data in config["mattermost"]["users"].items(): for name, data in config["mattermost"]["users"].items():
if "token" in data: if "token" in data:

View file

@ -14,7 +14,7 @@ def send_message(file_id, file_info, message):
# channel_id = MMApi().get_channel_id("bestuur-dev") # channel_id = MMApi().get_channel_id("bestuur-dev")
channel = ChannelApi( channel = ChannelApi(
channel_id=channel_id, channel_id=channel_id,
user=mattermost_client.users[config['mattermost']['selected_user']], user=mattermost_client.users[config["mattermost"]["selected_user"]],
) )
prefix = "" prefix = ""

View file

@ -71,7 +71,9 @@ def sync_file(drive, repo, path, sync_to):
repo.git.push("-u", "origin", branch_name) repo.git.push("-u", "origin", branch_name)
if not drive.mergerequests.list(source_branch=branch_name, state="opened"): if not drive.mergerequests.list(source_branch=branch_name, state="opened"):
if drive.mergerequests.list(source_branch=branch_name): if drive.mergerequests.list(source_branch=branch_name):
print(" Creating a new merge request to update the gitlab document with the new version from CodiMD.") print(
" Creating a new merge request to update the gitlab document with the new version from CodiMD."
)
drive.mergerequests.create( drive.mergerequests.create(
{ {
"source_branch": branch_name, "source_branch": branch_name,
@ -93,6 +95,7 @@ def sync_file(drive, repo, path, sync_to):
else: else:
print(" Note has no changes.") print(" Note has no changes.")
def init_sync(): def init_sync():
repo = get_repo() repo = get_repo()
gl = gitlab.Gitlab("https://git.zeus.gent", private_token=TOKEN) gl = gitlab.Gitlab("https://git.zeus.gent", private_token=TOKEN)

View file

@ -92,6 +92,7 @@ def validate_downloaded_files(post_mattermost_hint=True):
return db._load_db() return db._load_db()
def sync_files_to_gitlab(): def sync_files_to_gitlab():
repo, drive = sync_gitlab.init_sync() repo, drive = sync_gitlab.init_sync()
for file_id, file_info in db.get_files().items(): for file_id, file_info in db.get_files().items():
@ -103,6 +104,7 @@ def sync_files_to_gitlab():
except Exception as e: except Exception as e:
print("Critical error: Failed to sync file to Gitlab") print("Critical error: Failed to sync file to Gitlab")
def sync_files_to_gitea(): def sync_files_to_gitea():
repo, api_handler = sync.init_sync() repo, api_handler = sync.init_sync()
for file_id, file_info in db.get_files().items(): for file_id, file_info in db.get_files().items():
@ -115,6 +117,7 @@ def sync_files_to_gitea():
print("Critical error: Failed to sync file to Gitea") print("Critical error: Failed to sync file to Gitea")
traceback.print_exc() traceback.print_exc()
@hug.get("/sync-mattermost") @hug.get("/sync-mattermost")
def sync_mattermost(): def sync_mattermost():
print() print()