[CI] Format code with Black

This commit is contained in:
yunohost-bot 2022-01-24 18:16:08 +00:00
parent 981c7b5649
commit 71e73c7cf2
5 changed files with 39 additions and 23 deletions

View file

@ -155,7 +155,9 @@ def app_info(app, full=False):
ret["is_webapp"] = "domain" in settings and "path" in settings
if ret["is_webapp"]:
ret["is_default"] = domain_config_get(settings["domain"], "feature.app.default_app") == app
ret["is_default"] = (
domain_config_get(settings["domain"], "feature.app.default_app") == app
)
ret["supports_change_url"] = os.path.exists(
os.path.join(setting_path, "scripts", "change_url")
@ -1054,7 +1056,7 @@ def app_remove(operation_logger, app, purge=False):
hook_remove(app)
for domain in domain_list()["domains"]:
if (domain_config_get(domain, "feature.app.default_app") == app):
if domain_config_get(domain, "feature.app.default_app") == app:
domain_config_set(domain, "feature.app.default_app", "_none")
permission_sync_to_user()
@ -1086,9 +1088,9 @@ def app_makedefault(operation_logger, app, domain=None, undo=False):
operation_logger.start()
if undo:
domain_config_set(domain, 'feature.app.default_app', "_none")
domain_config_set(domain, "feature.app.default_app", "_none")
else:
domain_config_set(domain, 'feature.app.default_app', app)
domain_config_set(domain, "feature.app.default_app", app)
def app_setting(app, key, value=None, delete=False):
@ -1325,8 +1327,10 @@ def app_ssowatconf():
redirected_urls.update(app_settings.get("redirected_urls", {}))
redirected_regex.update(app_settings.get("redirected_regex", {}))
from .utils.legacy import translate_legacy_default_app_in_ssowant_conf_json_persistent
from .utils.legacy import (
translate_legacy_default_app_in_ssowant_conf_json_persistent,
)
translate_legacy_default_app_in_ssowant_conf_json_persistent()
for domain in domains:

View file

@ -656,9 +656,10 @@ class Diagnoser:
def _list_diagnosis_categories():
paths = glob.glob(os.path.dirname(__file__) + "/diagnosers/??-*.py")
names = [name.split("-")[-1] for name in sorted(
[os.path.basename(path)[: -len(".py")] for path in paths]
)]
names = [
name.split("-")[-1]
for name in sorted([os.path.basename(path)[: -len(".py")] for path in paths])
]
return names

View file

@ -455,7 +455,10 @@ class DomainConfigPanel(ConfigPanel):
save_mode = "diff"
def _apply(self):
if ("default_app" in self.future_values and self.future_values["default_app"] != self.values["default_app"]):
if (
"default_app" in self.future_values
and self.future_values["default_app"] != self.values["default_app"]
):
from yunohost.app import app_ssowatconf, app_map
if "/" in app_map(raw=True)[self.entity]:
@ -468,7 +471,7 @@ class DomainConfigPanel(ConfigPanel):
super()._apply()
app_ssowatconf()
def _get_toml(self):
from yunohost.dns import _get_registrar_config_section

View file

@ -1113,7 +1113,10 @@ class DomainQuestion(Question):
if self.default is None:
self.default = _get_maindomain()
self.choices = {domain: domain + '' if domain == self.default else '' for domain in domain_list()['domains']}
self.choices = {
domain: domain + "" if domain == self.default else ""
for domain in domain_list()["domains"]
}
@staticmethod
def normalize(value, option={}):
@ -1143,11 +1146,11 @@ class AppQuestion(Question):
apps = [app for app in apps if _filter in app and app[_filter]]
def _app_display(app):
domain_path = f" ({app['domain_path']})" if 'domain_path' in app else ""
domain_path = f" ({app['domain_path']})" if "domain_path" in app else ""
return app["label"] + domain_path
self.choices = {"_none": "---"}
self.choices.update({app['id']: _app_display(app) for app in apps})
self.choices.update({app["id"]: _app_display(app) for app in apps})
class UserQuestion(Question):
@ -1161,8 +1164,10 @@ class UserQuestion(Question):
super().__init__(question, context, hooks)
self.choices = {username: f"{infos['fullname']} ({infos['mail']})"
for username, infos in user_list()["users"].items()}
self.choices = {
username: f"{infos['fullname']} ({infos['mail']})"
for username, infos in user_list()["users"].items()
}
if not self.choices:
raise YunohostValidationError(

View file

@ -88,24 +88,27 @@ def translate_legacy_default_app_in_ssowant_conf_json_persistent():
redirected_urls = persistent["redirected_urls"]
if not any(from_url.count('/') == 1 and from_url.endswith('/') for from_url in redirected_urls):
if not any(
from_url.count("/") == 1 and from_url.endswith("/")
for from_url in redirected_urls
):
return
apps = app_list()['apps']
apps = app_list()["apps"]
if not any(app.get('domain_path') in redirected_urls.values() for app in apps):
if not any(app.get("domain_path") in redirected_urls.values() for app in apps):
return
for from_url, dest_url in redirected_urls.copy().items():
# Not a root domain, skip
if from_url.count('/') != 1 or not from_url.endswith('/'):
if from_url.count("/") != 1 or not from_url.endswith("/"):
continue
for app in apps:
if app.get('domain_path') != dest_url:
if app.get("domain_path") != dest_url:
continue
domain_config_set(from_url.strip('/'), "feature.app.default_app", app['id'])
domain_config_set(from_url.strip("/"), "feature.app.default_app", app["id"])
del redirected_urls[from_url]
persistent["redirected_urls"] = redirected_urls
write_to_json(persistent_file_name, persistent, sort_keys=True, indent=4)