Merge pull request #1686 from YunoHost/ci-format-debian/11.1.22

[CI] Format code with Black
This commit is contained in:
Alexandre Aubin 2023-07-10 19:07:00 +02:00 committed by GitHub
commit 89ffe624f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 17 deletions

View file

@ -2784,9 +2784,12 @@ def _check_manifest_requirements(
# Some apps have a higher runtime value than build ... # Some apps have a higher runtime value than build ...
if ram_requirement["build"] != "?" and ram_requirement["runtime"] != "?": if ram_requirement["build"] != "?" and ram_requirement["runtime"] != "?":
max_build_runtime = (ram_requirement["build"] max_build_runtime = (
if human_to_binary(ram_requirement["build"]) > human_to_binary(ram_requirement["runtime"]) ram_requirement["build"]
else ram_requirement["runtime"]) if human_to_binary(ram_requirement["build"])
> human_to_binary(ram_requirement["runtime"])
else ram_requirement["runtime"]
)
else: else:
max_build_runtime = ram_requirement["build"] max_build_runtime = ram_requirement["build"]

View file

@ -182,7 +182,7 @@ class MyDiagnoser(Diagnoser):
if success != "ok": if success != "ok":
return None return None
else: else:
if type_ == "TXT" and isinstance(answers,list): if type_ == "TXT" and isinstance(answers, list):
for part in answers: for part in answers:
if part.startswith('"v=spf1'): if part.startswith('"v=spf1'):
return part return part

View file

@ -339,7 +339,9 @@ def test_app_from_catalog():
assert app_map_[main_domain]["/site"]["id"] == "my_webapp" assert app_map_[main_domain]["/site"]["id"] == "my_webapp"
assert app_is_installed(main_domain, "my_webapp") assert app_is_installed(main_domain, "my_webapp")
assert app_is_exposed_on_http(main_domain, "/site", "you have just installed My Webapp") assert app_is_exposed_on_http(
main_domain, "/site", "you have just installed My Webapp"
)
# Try upgrade, should do nothing # Try upgrade, should do nothing
app_upgrade("my_webapp") app_upgrade("my_webapp")

View file

@ -71,9 +71,13 @@ def test_repo_url_definition():
### Gitea ### Gitea
assert _is_app_repo_url("https://gitea.instance.tld/user/repo_ynh") assert _is_app_repo_url("https://gitea.instance.tld/user/repo_ynh")
assert _is_app_repo_url("https://gitea.instance.tld/user/repo_ynh/src/branch/branch_name") assert _is_app_repo_url(
"https://gitea.instance.tld/user/repo_ynh/src/branch/branch_name"
)
assert _is_app_repo_url("https://gitea.instance.tld/user/repo_ynh/src/tag/tag_name") assert _is_app_repo_url("https://gitea.instance.tld/user/repo_ynh/src/tag/tag_name")
assert _is_app_repo_url("https://gitea.instance.tld/user/repo_ynh/src/commit/abcd1234") assert _is_app_repo_url(
"https://gitea.instance.tld/user/repo_ynh/src/commit/abcd1234"
)
### Invalid patterns ### Invalid patterns

View file

@ -1065,9 +1065,11 @@ class AptDependenciesAppResource(AppResource):
if isinstance(values.get("packages"), str): if isinstance(values.get("packages"), str):
values["packages"] = [value.strip() for value in values["packages"].split(",")] # type: ignore values["packages"] = [value.strip() for value in values["packages"].split(",")] # type: ignore
if not isinstance(values.get("repo"), str) \ if (
or not isinstance(values.get("key"), str) \ not isinstance(values.get("repo"), str)
or not isinstance(values.get("packages"), list): or not isinstance(values.get("key"), str)
or not isinstance(values.get("packages"), list)
):
raise YunohostError( raise YunohostError(
"In apt resource in the manifest: 'extras' repo should have the keys 'repo', 'key' defined as strings and 'packages' defined as list", "In apt resource in the manifest: 'extras' repo should have the keys 'repo', 'key' defined as strings and 'packages' defined as list",
raw_msg=True, raw_msg=True,
@ -1076,12 +1078,14 @@ class AptDependenciesAppResource(AppResource):
def provision_or_update(self, context: Dict = {}): def provision_or_update(self, context: Dict = {}):
script = " ".join(["ynh_install_app_dependencies", *self.packages]) script = " ".join(["ynh_install_app_dependencies", *self.packages])
for repo, values in self.extras.items(): for repo, values in self.extras.items():
script += "\n" + " ".join([ script += "\n" + " ".join(
"ynh_install_extra_app_dependencies", [
f"--repo='{values['repo']}'", "ynh_install_extra_app_dependencies",
f"--key='{values['key']}'", f"--repo='{values['repo']}'",
f"--package='{' '.join(values['packages'])}'" f"--key='{values['key']}'",
]) f"--package='{' '.join(values['packages'])}'",
]
)
# FIXME : we're feeding the raw value of values['packages'] to the helper .. if we want to be consistent, may they should be comma-separated, though in the majority of cases, only a single package is installed from an extra repo.. # FIXME : we're feeding the raw value of values['packages'] to the helper .. if we want to be consistent, may they should be comma-separated, though in the majority of cases, only a single package is installed from an extra repo..
self._run_script("provision_or_update", script) self._run_script("provision_or_update", script)