36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Legt eine Route aus einer GPX-Datei an."""
|
|
|
|
import argparse
|
|
from collections.abc import Sequence
|
|
|
|
from common import add_common_arguments, ask, ask_path, client_from_args, run
|
|
|
|
|
|
def build_parser() -> argparse.ArgumentParser:
|
|
parser = argparse.ArgumentParser(description="Neue Wegwichtel-Route anlegen")
|
|
add_common_arguments(parser)
|
|
parser.add_argument("--gpx")
|
|
parser.add_argument("--name")
|
|
parser.add_argument("--slug")
|
|
parser.add_argument("--description")
|
|
parser.add_argument("--school-name")
|
|
return parser
|
|
|
|
|
|
def main(argv: Sequence[str] | None = None):
|
|
args = build_parser().parse_args(argv)
|
|
client = client_from_args(args)
|
|
gpx = ask_path("GPX-Datei", args.gpx)
|
|
fields = {
|
|
"name": ask("Name (leer: GPX-Name)", args.name),
|
|
"slug": ask("Slug (leer: automatisch)", args.slug),
|
|
"description": ask("Beschreibung", args.description),
|
|
"schoolName": ask("Schule", args.school_name),
|
|
}
|
|
return client.request("POST", "/api/routes", fields=fields, files={"gpx": gpx})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run(main)
|