mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[CI] Format code with Black
This commit is contained in:
parent
981c7b5649
commit
71e73c7cf2
5 changed files with 39 additions and 23 deletions
16
src/app.py
16
src/app.py
|
@ -155,7 +155,9 @@ def app_info(app, full=False):
|
||||||
ret["is_webapp"] = "domain" in settings and "path" in settings
|
ret["is_webapp"] = "domain" in settings and "path" in settings
|
||||||
|
|
||||||
if ret["is_webapp"]:
|
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(
|
ret["supports_change_url"] = os.path.exists(
|
||||||
os.path.join(setting_path, "scripts", "change_url")
|
os.path.join(setting_path, "scripts", "change_url")
|
||||||
|
@ -1054,7 +1056,7 @@ def app_remove(operation_logger, app, purge=False):
|
||||||
hook_remove(app)
|
hook_remove(app)
|
||||||
|
|
||||||
for domain in domain_list()["domains"]:
|
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")
|
domain_config_set(domain, "feature.app.default_app", "_none")
|
||||||
|
|
||||||
permission_sync_to_user()
|
permission_sync_to_user()
|
||||||
|
@ -1086,9 +1088,9 @@ def app_makedefault(operation_logger, app, domain=None, undo=False):
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
|
||||||
if undo:
|
if undo:
|
||||||
domain_config_set(domain, 'feature.app.default_app', "_none")
|
domain_config_set(domain, "feature.app.default_app", "_none")
|
||||||
else:
|
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):
|
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_urls.update(app_settings.get("redirected_urls", {}))
|
||||||
redirected_regex.update(app_settings.get("redirected_regex", {}))
|
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()
|
translate_legacy_default_app_in_ssowant_conf_json_persistent()
|
||||||
|
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
|
|
|
@ -656,9 +656,10 @@ class Diagnoser:
|
||||||
def _list_diagnosis_categories():
|
def _list_diagnosis_categories():
|
||||||
|
|
||||||
paths = glob.glob(os.path.dirname(__file__) + "/diagnosers/??-*.py")
|
paths = glob.glob(os.path.dirname(__file__) + "/diagnosers/??-*.py")
|
||||||
names = [name.split("-")[-1] for name in sorted(
|
names = [
|
||||||
[os.path.basename(path)[: -len(".py")] for path in paths]
|
name.split("-")[-1]
|
||||||
)]
|
for name in sorted([os.path.basename(path)[: -len(".py")] for path in paths])
|
||||||
|
]
|
||||||
|
|
||||||
return names
|
return names
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,10 @@ class DomainConfigPanel(ConfigPanel):
|
||||||
save_mode = "diff"
|
save_mode = "diff"
|
||||||
|
|
||||||
def _apply(self):
|
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
|
from yunohost.app import app_ssowatconf, app_map
|
||||||
|
|
||||||
if "/" in app_map(raw=True)[self.entity]:
|
if "/" in app_map(raw=True)[self.entity]:
|
||||||
|
@ -468,7 +471,7 @@ class DomainConfigPanel(ConfigPanel):
|
||||||
|
|
||||||
super()._apply()
|
super()._apply()
|
||||||
app_ssowatconf()
|
app_ssowatconf()
|
||||||
|
|
||||||
def _get_toml(self):
|
def _get_toml(self):
|
||||||
from yunohost.dns import _get_registrar_config_section
|
from yunohost.dns import _get_registrar_config_section
|
||||||
|
|
||||||
|
|
|
@ -1113,7 +1113,10 @@ class DomainQuestion(Question):
|
||||||
if self.default is None:
|
if self.default is None:
|
||||||
self.default = _get_maindomain()
|
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
|
@staticmethod
|
||||||
def normalize(value, option={}):
|
def normalize(value, option={}):
|
||||||
|
@ -1143,11 +1146,11 @@ class AppQuestion(Question):
|
||||||
apps = [app for app in apps if _filter in app and app[_filter]]
|
apps = [app for app in apps if _filter in app and app[_filter]]
|
||||||
|
|
||||||
def _app_display(app):
|
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
|
return app["label"] + domain_path
|
||||||
|
|
||||||
self.choices = {"_none": "---"}
|
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):
|
class UserQuestion(Question):
|
||||||
|
@ -1161,8 +1164,10 @@ class UserQuestion(Question):
|
||||||
|
|
||||||
super().__init__(question, context, hooks)
|
super().__init__(question, context, hooks)
|
||||||
|
|
||||||
self.choices = {username: f"{infos['fullname']} ({infos['mail']})"
|
self.choices = {
|
||||||
for username, infos in user_list()["users"].items()}
|
username: f"{infos['fullname']} ({infos['mail']})"
|
||||||
|
for username, infos in user_list()["users"].items()
|
||||||
|
}
|
||||||
|
|
||||||
if not self.choices:
|
if not self.choices:
|
||||||
raise YunohostValidationError(
|
raise YunohostValidationError(
|
||||||
|
|
|
@ -88,24 +88,27 @@ def translate_legacy_default_app_in_ssowant_conf_json_persistent():
|
||||||
|
|
||||||
redirected_urls = persistent["redirected_urls"]
|
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
|
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
|
return
|
||||||
|
|
||||||
for from_url, dest_url in redirected_urls.copy().items():
|
for from_url, dest_url in redirected_urls.copy().items():
|
||||||
# Not a root domain, skip
|
# 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
|
continue
|
||||||
for app in apps:
|
for app in apps:
|
||||||
if app.get('domain_path') != dest_url:
|
if app.get("domain_path") != dest_url:
|
||||||
continue
|
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]
|
del redirected_urls[from_url]
|
||||||
|
|
||||||
persistent["redirected_urls"] = redirected_urls
|
persistent["redirected_urls"] = redirected_urls
|
||||||
|
|
||||||
write_to_json(persistent_file_name, persistent, sort_keys=True, indent=4)
|
write_to_json(persistent_file_name, persistent, sort_keys=True, indent=4)
|
||||||
|
|
Loading…
Add table
Reference in a new issue