From e15a2e41e8181cba91426ca7119be90b9d72246b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 15 Sep 2023 17:01:49 +0200 Subject: [PATCH] cleanup update scripts, run isort --- .github/workflows/update_extensions.py | 19 +++++++------------ .github/workflows/updater.py | 9 ++++----- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/update_extensions.py b/.github/workflows/update_extensions.py index 44e0b95..d7c018a 100755 --- a/.github/workflows/update_extensions.py +++ b/.github/workflows/update_extensions.py @@ -3,14 +3,13 @@ Download extensions for the current mediawiki version, and update the conf files. """ -from typing import List, Optional, Any -import hashlib -import urllib import datetime -from html.parser import HTMLParser +import hashlib +from typing import Any, List, Optional + +import requests import tomlkit from packaging import version -import requests GITHUB_API_URL = "https://api.github.com/repos" @@ -87,13 +86,9 @@ def get_last_commit_of(repo: str, branch: str) -> str: return commit["sha"] -def timestamp_of_commit(repo: str, sha: str) -> int: +def timestamp_of_commit(repo: str, sha: str) -> datetime.datetime: commit = github_get(f"{repo}/commits/{sha}") - try: - date = commit["commit"]["author"]["date"] - except : - print(date) - raise + date = commit["commit"]["author"]["date"] return datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ") @@ -101,7 +96,7 @@ def main(): print('Updating extensions source files...') with open("manifest.toml", "r", encoding="utf-8") as file: manifest = tomlkit.loads(file.read()) - mediawiki_version = version.Version(manifest["version"].value.split("~")[0]) + # mediawiki_version = version.Version(manifest["version"].value.split("~")[0]) for name, descr in manifest["resources"]["sources"].items(): if "extension" not in descr["url"]: diff --git a/.github/workflows/updater.py b/.github/workflows/updater.py index b976fb7..49528ec 100755 --- a/.github/workflows/updater.py +++ b/.github/workflows/updater.py @@ -12,14 +12,13 @@ You need to enable the action by removing `if ${{ false }}` in updater.yml! import hashlib import logging import os -from subprocess import run, PIPE import textwrap -from typing import List, Tuple, Any, Optional +from subprocess import PIPE, run +from typing import Any, List, Optional, Tuple + import requests -from packaging import version - import tomlkit - +from packaging import version logging.getLogger().setLevel(logging.INFO)