mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
🎨 Format Python code with Black
This commit is contained in:
parent
ccc005fb84
commit
ea6eaa6b1e
4 changed files with 18 additions and 13 deletions
|
@ -428,7 +428,9 @@ class ActionsMap:
|
||||||
actionsmap = read_yaml(actionsmap_yml)
|
actionsmap = read_yaml(actionsmap_yml)
|
||||||
|
|
||||||
# Delete old cache files
|
# Delete old cache files
|
||||||
for old_cache in glob.glob("{}/actionsmap/{}-*.pkl".format(CACHE_DIR, n)):
|
for old_cache in glob.glob(
|
||||||
|
"{}/actionsmap/{}-*.pkl".format(CACHE_DIR, n)
|
||||||
|
):
|
||||||
os.remove(old_cache)
|
os.remove(old_cache)
|
||||||
|
|
||||||
# at installation, cachedir might not exists
|
# at installation, cachedir might not exists
|
||||||
|
|
|
@ -224,9 +224,8 @@ class _CallbackAction(argparse.Action):
|
||||||
# Execute callback and get returned value
|
# Execute callback and get returned value
|
||||||
value = self.callback(namespace, values, **self.callback_kwargs)
|
value = self.callback(namespace, values, **self.callback_kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error_message = (
|
error_message = "cannot get value from callback method " "'{}': {}".format(
|
||||||
"cannot get value from callback method "
|
self.callback_method, e
|
||||||
"'{}': {}".format(self.callback_method, e)
|
|
||||||
)
|
)
|
||||||
logger.exception(error_message)
|
logger.exception(error_message)
|
||||||
raise MoulinetteError(error_message, raw_msg=True)
|
raise MoulinetteError(error_message, raw_msg=True)
|
||||||
|
|
|
@ -38,9 +38,7 @@ logger = log.getLogger("moulinette.interface.api")
|
||||||
# We define a global variable to manage in a dirty way the upload...
|
# We define a global variable to manage in a dirty way the upload...
|
||||||
UPLOAD_DIR = None
|
UPLOAD_DIR = None
|
||||||
|
|
||||||
CSRF_TYPES = {
|
CSRF_TYPES = {"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"}
|
||||||
"text/plain", "application/x-www-form-urlencoded", "multipart/form-data"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def is_csrf():
|
def is_csrf():
|
||||||
|
@ -667,7 +665,9 @@ class ActionsMapParser(BaseActionsMapParser):
|
||||||
# Retrieve the tid for the route
|
# Retrieve the tid for the route
|
||||||
_, parser = self._parsers[route]
|
_, parser = self._parsers[route]
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
error_message = "no argument parser found for route '{}': {}".format(route, e)
|
error_message = "no argument parser found for route '{}': {}".format(
|
||||||
|
route, e
|
||||||
|
)
|
||||||
logger.error(error_message)
|
logger.error(error_message)
|
||||||
raise MoulinetteValidationError(error_message, raw_msg=True)
|
raise MoulinetteValidationError(error_message, raw_msg=True)
|
||||||
|
|
||||||
|
@ -684,7 +684,9 @@ class ActionsMapParser(BaseActionsMapParser):
|
||||||
# Retrieve the parser for the route
|
# Retrieve the parser for the route
|
||||||
_, parser = self._parsers[route]
|
_, parser = self._parsers[route]
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
error_message = "no argument parser found for route '{}': {}".format(route, e)
|
error_message = "no argument parser found for route '{}': {}".format(
|
||||||
|
route, e
|
||||||
|
)
|
||||||
logger.error(error_message)
|
logger.error(error_message)
|
||||||
raise MoulinetteValidationError(error_message, raw_msg=True)
|
raise MoulinetteValidationError(error_message, raw_msg=True)
|
||||||
ret = argparse.Namespace()
|
ret = argparse.Namespace()
|
||||||
|
|
|
@ -192,10 +192,12 @@ def test_extra_argument_parser_add_argument_bad_arg(iface):
|
||||||
with pytest.raises(MoulinetteError) as exception:
|
with pytest.raises(MoulinetteError) as exception:
|
||||||
extra_argument_parse.add_argument("_global", "foo", {"ask": 1})
|
extra_argument_parse.add_argument("_global", "foo", {"ask": 1})
|
||||||
|
|
||||||
expected_msg = "unable to validate extra parameter '{}' for argument '{}': {}".format(
|
expected_msg = (
|
||||||
"ask",
|
"unable to validate extra parameter '{}' for argument '{}': {}".format(
|
||||||
"foo",
|
"ask",
|
||||||
"parameter value must be a string, got 1",
|
"foo",
|
||||||
|
"parameter value must be a string, got 1",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
assert expected_msg in str(exception)
|
assert expected_msg in str(exception)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue