This commit is contained in:
+27
-11
@@ -1,15 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Legt einen POI für eine Route an."""
|
||||
|
||||
import argparse
|
||||
from collections.abc import Sequence
|
||||
|
||||
from common import add_common_arguments, ask, client_from_args, run
|
||||
parser = argparse.ArgumentParser(description="POI anlegen")
|
||||
add_common_arguments(parser)
|
||||
for name, kwargs in [
|
||||
("--route-id", {"type": int}), ("--title", {}), ("--description", {}),
|
||||
("--lat", {"type": float}), ("--lon", {"type": float}),
|
||||
("--trigger-radius", {"type": float}), ("--sequence", {"type": int})
|
||||
]: parser.add_argument(name, **kwargs)
|
||||
args = parser.parse_args()
|
||||
def action():
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="POI anlegen")
|
||||
add_common_arguments(parser)
|
||||
parser.add_argument("--route-id", type=int)
|
||||
parser.add_argument("--title")
|
||||
parser.add_argument("--description")
|
||||
parser.add_argument("--lat", type=float)
|
||||
parser.add_argument("--lon", type=float)
|
||||
parser.add_argument("--trigger-radius", type=float)
|
||||
parser.add_argument("--sequence", type=int)
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None):
|
||||
args = build_parser().parse_args(argv)
|
||||
client = client_from_args(args)
|
||||
route_id = ask("Route-ID", args.route_id, required=True, cast=int)
|
||||
body = {
|
||||
@@ -20,5 +32,9 @@ def action():
|
||||
"triggerRadiusM": ask("Auslöseradius in Metern", args.trigger_radius, cast=float),
|
||||
"sequence": ask("Reihenfolge", args.sequence, cast=int),
|
||||
}
|
||||
return client.request("POST", f"/api/routes/{route_id}/pois", json_body={k:v for k,v in body.items() if v is not None})
|
||||
run(action)
|
||||
payload = {key: value for key, value in body.items() if value is not None}
|
||||
return client.request("POST", f"/api/routes/{route_id}/pois", json_body=payload)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(main)
|
||||
|
||||
Reference in New Issue
Block a user