Skip to content

Commit 13195cb

Browse files
committed
fix formatting
1 parent 1e254c0 commit 13195cb

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

ci/src/_utils.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# -*-coding: utf-8 -*-
22
import json
3+
import os
4+
import re
35
from pathlib import Path
46
from typing import Dict, List, TypeVar
5-
import re
6-
import os
77

88
# If adding a third-party library here, check CI workflows Python files
99
# that are dependant on this and require pip install.
@@ -20,7 +20,18 @@
2020
# constants
2121
id_name = "ID"
2222
language_name = "Language"
23-
language_list = ("csharp", "executable", "fsharp", "python", "javascript", "typescript", "python_v2", "executable_v2", "javascript_v2", "typescript_v2")
23+
language_list = (
24+
"csharp",
25+
"executable",
26+
"fsharp",
27+
"python",
28+
"javascript",
29+
"typescript",
30+
"python_v2",
31+
"executable_v2",
32+
"javascript_v2",
33+
"typescript_v2",
34+
)
2435
etag = "ETag"
2536
version = "Version"
2637
url_sourcecode = "UrlSourceCode"
@@ -54,16 +65,20 @@ def plugin_reader() -> P:
5465

5566
return manifests
5667

68+
5769
def save_plugins_json_file(content: list[dict[str]]) -> None:
5870
with open("plugins.json", "w", encoding="utf-8") as f:
5971
json.dump(content, f, indent=4, ensure_ascii=False)
6072

73+
6174
def get_plugin_file_paths() -> list[str]:
6275
return [os.path.join(plugin_dir, filename) for filename in get_plugin_filenames()]
6376

77+
6478
def get_plugin_filenames() -> list[str]:
6579
return os.listdir(plugin_dir)
6680

81+
6782
def etag_reader() -> ETagsType:
6883
with open(etag_file, "r", encoding="utf-8") as f:
6984
return json.load(f)
@@ -74,6 +89,7 @@ def plugin_writer(content: P):
7489
with open(plugin_dir / f"{plugin[plugin_name]}-{plugin[id_name]}.json", "w", encoding="utf-8") as f:
7590
json.dump(plugin, f, indent=4)
7691

92+
7793
def etags_writer(content: ETagsType):
7894
with open(etag_file, "w", encoding="utf-8") as f:
7995
json.dump(content, f, indent=4)
@@ -82,10 +98,12 @@ def etags_writer(content: ETagsType):
8298
def clean(string: str, flag="-") -> str:
8399
return string.lower().replace(flag, "").strip()
84100

101+
85102
def version_tuple(version: str) -> tuple:
86103
version = clean(version, "v")
87104
return tuple(version.split("."))
88105

106+
89107
def check_url(url: str) -> bool:
90108
regex = re.compile(
91109
r"^(?:http|ftp)s?://" # http:// or https://
@@ -108,6 +126,7 @@ def get_file_plugins_json_info(required_key: str = "") -> list[dict[str, str]]:
108126

109127
return [{required_key: plugin[required_key]} for plugin in data]
110128

129+
111130
def get_new_plugin_submission_ids() -> list[str]:
112131
plugins_json_ids = [item["ID"] for item in get_file_plugins_json_info("ID")]
113132
existing_plugin_file_ids = [info["ID"] for info in plugin_reader()]

ci/src/merge-manifest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import sys
2+
23
from _utils import get_new_plugin_submission_ids, plugin_reader, save_plugins_json_file
34

5+
46
def get_all_plugins() -> list[dict[str]]:
57
return plugin_reader()
68

9+
710
def get_new_plugins() -> list[dict[str]]:
811
ids = get_new_plugin_submission_ids()
912
plugins_from_plugins_dir = plugin_reader()

ci/src/validator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*-coding: utf-8 -*-
22
import uuid
33

4-
from _utils import (check_url, clean, get_plugin_file_paths, get_plugin_filenames,
5-
icon_path, id_name, language_list, language_name, plugin_reader, get_new_plugin_submission_ids)
4+
from _utils import (check_url, clean, get_new_plugin_submission_ids, get_plugin_file_paths, get_plugin_filenames,
5+
icon_path, id_name, language_list, language_name, plugin_reader)
66

77
plugin_infos = plugin_reader()
88

@@ -22,23 +22,27 @@ def test_language_in_list():
2222
msg = f"The '{language_name}' is not in the list of {language_list}"
2323
assert set(language_list) >= set(languages), msg
2424

25+
2526
def test_valid_icon_url():
2627
for plugin in plugin_infos:
2728
msg = f"The URL in {icon_path} is not a valid URL."
2829
assert check_url(plugin[icon_path]), msg
2930

31+
3032
def test_file_type_json():
3133
incorrect_ext_files = [file_path for file_path in get_plugin_file_paths() if not file_path.endswith(".json")]
3234

3335
assert len(incorrect_ext_files) == 0, f"Expected the following file to be of .json extension: {incorrect_ext_files}"
3436

37+
3538
def test_file_name_construct():
3639
filenames = get_plugin_filenames()
3740
for info in plugin_infos:
3841
assert (
3942
f"{info['Name']}-{info['ID']}.json" in filenames
4043
), f"Plugin {info['Name']} with ID {info['ID']} does not have the correct filename. Make sure it's name + ID, i.e. {info['Name']}-{info['ID']}.json"
4144

45+
4246
def test_submitted_plugin_id_is_valid_uuid():
4347
for id in get_new_plugin_submission_ids():
4448
try:

0 commit comments

Comments
 (0)