From a6c976b309170681b081dbcff2f68b03fe24017a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Wed, 7 Feb 2024 14:49:55 +0100 Subject: [PATCH] python: run isort, add shebangs on all files --- README-generator/__init__.py | 1 + README-generator/make_readme.py | 3 ++- README-generator/webhook.py | 13 +++++++------ __init__.py | 1 + autopatches/autopatch.py | 6 ++++-- autopatches/patches/add-cpe/patch.sh | 3 ++- autoupdate_app_sources/autoupdate_app_sources.py | 12 +++++++----- autoupdate_app_sources/rest_api.py | 7 +++++-- autoupdater-upgrader/autoupdater-upgrader.py | 13 ++++++++----- bot-repo-cleanup/cleanup.py | 2 +- catalog_linter.py | 2 +- packaging_v2/__init__.py | 1 + packaging_v2/convert_app_to_packaging_v2.py | 7 +++++-- .../convert_v1_manifest_to_v2_for_catalog.py | 2 ++ update_app_levels/update_app_levels.py | 13 ++++++++----- 15 files changed, 55 insertions(+), 31 deletions(-) diff --git a/README-generator/__init__.py b/README-generator/__init__.py index e69de29..e5a0d9b 100644 --- a/README-generator/__init__.py +++ b/README-generator/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 diff --git a/README-generator/make_readme.py b/README-generator/make_readme.py index 5f004ea..d71f973 100755 --- a/README-generator/make_readme.py +++ b/README-generator/make_readme.py @@ -2,12 +2,13 @@ import argparse import json -import toml import os from pathlib import Path +import toml from jinja2 import Environment, FileSystemLoader + def value_for_lang(values, lang): if not isinstance(values, dict): return values diff --git a/README-generator/webhook.py b/README-generator/webhook.py index af220d8..7a76eab 100755 --- a/README-generator/webhook.py +++ b/README-generator/webhook.py @@ -1,15 +1,16 @@ -import os -import hmac -import shlex -import hashlib +#!/usr/bin/env python3 + import asyncio +import hashlib +import hmac +import os +import shlex import tempfile +from make_readme import generate_READMEs from sanic import Sanic, response from sanic.response import text -from make_readme import generate_READMEs - app = Sanic(__name__) github_webhook_secret = open("github_webhook_secret", "r").read().strip() diff --git a/__init__.py b/__init__.py index e69de29..e5a0d9b 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 diff --git a/autopatches/autopatch.py b/autopatches/autopatch.py index 746ee51..6f52d30 100755 --- a/autopatches/autopatch.py +++ b/autopatches/autopatch.py @@ -1,9 +1,11 @@ #!/usr/bin/python3 + import json -import sys -import requests import os import subprocess +import sys + +import requests catalog = requests.get("https://raw.githubusercontent.com/YunoHost/apps/master/apps.json").json() diff --git a/autopatches/patches/add-cpe/patch.sh b/autopatches/patches/add-cpe/patch.sh index 02a697c..2b6b2d6 100644 --- a/autopatches/patches/add-cpe/patch.sh +++ b/autopatches/patches/add-cpe/patch.sh @@ -1,7 +1,8 @@ #!/usr/bin/python3 -import json import csv +import json + def find_cpe(app_id): with open("../../patches/add-cpe/cpe.csv", newline='') as f: diff --git a/autoupdate_app_sources/autoupdate_app_sources.py b/autoupdate_app_sources/autoupdate_app_sources.py index dfd15b7..b42dc78 100644 --- a/autoupdate_app_sources/autoupdate_app_sources.py +++ b/autoupdate_app_sources/autoupdate_app_sources.py @@ -1,13 +1,15 @@ -import time +#!/usr/bin/env python3 + +import glob import hashlib +import os import re import sys -import requests -import toml -import os -import glob +import time from datetime import datetime +import requests +import toml from rest_api import GithubAPI, GitlabAPI, RefType STRATEGIES = [ diff --git a/autoupdate_app_sources/rest_api.py b/autoupdate_app_sources/rest_api.py index a76821a..ccc6b4d 100644 --- a/autoupdate_app_sources/rest_api.py +++ b/autoupdate_app_sources/rest_api.py @@ -1,8 +1,11 @@ -from enum import Enum +#!/usr/bin/env python3 + import re -import requests +from enum import Enum from typing import List +import requests + class RefType(Enum): tags = 1 diff --git a/autoupdater-upgrader/autoupdater-upgrader.py b/autoupdater-upgrader/autoupdater-upgrader.py index 7252042..3e9c1a2 100755 --- a/autoupdater-upgrader/autoupdater-upgrader.py +++ b/autoupdater-upgrader/autoupdater-upgrader.py @@ -1,14 +1,17 @@ -#!venv/bin/python3 +#!/usr/bin/env python3 -import sys, os, time -import urllib.request, json +import json +import os import re +import sys +import time +import urllib.request -from github import Github import github - +from github import Github # Debug from rich.traceback import install + install(width=150, show_locals=True, locals_max_length=None, locals_max_string=None) ##### diff --git a/bot-repo-cleanup/cleanup.py b/bot-repo-cleanup/cleanup.py index f2275c6..2a9fa98 100644 --- a/bot-repo-cleanup/cleanup.py +++ b/bot-repo-cleanup/cleanup.py @@ -1,4 +1,4 @@ -#!venv/bin/python3 +#!/usr/bin/env python3 # Obtained with `pip install PyGithub`, better within a venv from github import Github diff --git a/catalog_linter.py b/catalog_linter.py index 4c383a9..6ce7ef9 100755 --- a/catalog_linter.py +++ b/catalog_linter.py @@ -2,10 +2,10 @@ import json import sys +from difflib import SequenceMatcher from functools import cache from pathlib import Path from typing import Any, Dict, Generator, List, Tuple -from difflib import SequenceMatcher import jsonschema import toml diff --git a/packaging_v2/__init__.py b/packaging_v2/__init__.py index e69de29..e5a0d9b 100644 --- a/packaging_v2/__init__.py +++ b/packaging_v2/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/env python3 diff --git a/packaging_v2/convert_app_to_packaging_v2.py b/packaging_v2/convert_app_to_packaging_v2.py index 7887cdb..2fa166c 100644 --- a/packaging_v2/convert_app_to_packaging_v2.py +++ b/packaging_v2/convert_app_to_packaging_v2.py @@ -1,7 +1,9 @@ +#!/usr/bin/env python3 + import argparse +import json import os import re -import json import subprocess from glob import glob @@ -226,7 +228,8 @@ def _convert_v1_manifest_to_v2(app_path): def _dump_v2_manifest_as_toml(manifest): import re - from tomlkit import document, nl, table, dumps, comment + + from tomlkit import comment, document, dumps, nl, table toml_manifest = document() toml_manifest.add("packaging_format", 2) diff --git a/packaging_v2/convert_v1_manifest_to_v2_for_catalog.py b/packaging_v2/convert_v1_manifest_to_v2_for_catalog.py index 0130c29..9fb3790 100644 --- a/packaging_v2/convert_v1_manifest_to_v2_for_catalog.py +++ b/packaging_v2/convert_v1_manifest_to_v2_for_catalog.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import copy diff --git a/update_app_levels/update_app_levels.py b/update_app_levels/update_app_levels.py index b8df4a1..221d4f2 100644 --- a/update_app_levels/update_app_levels.py +++ b/update_app_levels/update_app_levels.py @@ -1,12 +1,15 @@ -import time -import toml -import requests -import tempfile +#!/usr/bin/env python3 + +import json import os import sys -import json +import tempfile +import time from collections import OrderedDict +import requests +import toml + token = open(os.path.dirname(__file__) + "/../../.github_token").read().strip() tmpdir = tempfile.mkdtemp(prefix="update_app_levels_")