Reformatted code base using black.

This commit is contained in:
Goffi 2024-06-19 18:44:57 +02:00
commit 53fdaa9d09

View file

@ -131,45 +131,53 @@ class Disco(base.CommandBase):
data = {k: e[k] for k in sorted(e)}
host = data.pop("host")
type_ = data.pop("type")
fmt_lines.append(A.color(
"\t",
C.A_SUBHEADER,
host,
" ",
A.RESET,
"[",
C.A_LEVEL_COLORS[1],
type_,
A.RESET,
"]",
))
fmt_lines.append(
A.color(
"\t",
C.A_SUBHEADER,
host,
" ",
A.RESET,
"[",
C.A_LEVEL_COLORS[1],
type_,
A.RESET,
"]",
)
)
extended = data.pop("extended", None)
for key, value in data.items():
fmt_lines.append(A.color(
"\t\t",
C.A_LEVEL_COLORS[2],
f"{key}: ",
C.A_LEVEL_COLORS[3],
str(value)
))
fmt_lines.append(
A.color(
"\t\t",
C.A_LEVEL_COLORS[2],
f"{key}: ",
C.A_LEVEL_COLORS[3],
str(value),
)
)
if extended:
fmt_lines.append(A.color(
"\t\t",
C.A_HEADER,
"extended",
))
fmt_lines.append(
A.color(
"\t\t",
C.A_HEADER,
"extended",
)
)
nb_extended = len(extended)
for idx, form_data in enumerate(extended):
namespace = form_data.get("namespace")
if namespace:
fmt_lines.append(A.color(
"\t\t",
C.A_LEVEL_COLORS[2],
"namespace: ",
C.A_LEVEL_COLORS[3],
A.BOLD,
namespace
))
fmt_lines.append(
A.color(
"\t\t",
C.A_LEVEL_COLORS[2],
"namespace: ",
C.A_LEVEL_COLORS[3],
A.BOLD,
namespace,
)
)
for field_data in form_data["fields"]:
name = field_data.get("name")
if not name:
@ -183,15 +191,17 @@ class Disco(base.CommandBase):
continue
if field_type == "boolean":
value = C.bool(value)
fmt_lines.append(A.color(
"\t\t",
C.A_LEVEL_COLORS[2],
f"{name}: ",
C.A_LEVEL_COLORS[3],
A.BOLD,
str(value)
))
if nb_extended>1 and idx < nb_extended-1:
fmt_lines.append(
A.color(
"\t\t",
C.A_LEVEL_COLORS[2],
f"{name}: ",
C.A_LEVEL_COLORS[3],
A.BOLD,
str(value),
)
)
if nb_extended > 1 and idx < nb_extended - 1:
fmt_lines.append("\n")
fmt_lines.append("\n")
@ -218,7 +228,7 @@ class Disco(base.CommandBase):
if self.args.node:
if self.args.type == "external":
self.parser.error(
'--node can\'t be used with discovery of external services '
"--node can't be used with discovery of external services "
'(--type="external")'
)
else:
@ -245,7 +255,11 @@ class Disco(base.CommandBase):
features.sort()
identities.sort(key=lambda identity: identity[2])
data.update(
{"features": features, "identities": identities, "extensions": extensions}
{
"features": features,
"identities": identities,
"extensions": extensions,
}
)
# items
@ -274,7 +288,7 @@ class Disco(base.CommandBase):
except Exception as e:
self.disp(
_("error while doing external service discovery: {e}").format(e=e),
error=True
error=True,
)
self.host.quit(C.EXIT_BRIDGE_ERRBACK)
else: