This commit is contained in:
@@ -1,17 +1,25 @@
|
||||
#!/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
|
||||
|
||||
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")
|
||||
args = parser.parse_args()
|
||||
|
||||
def action():
|
||||
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 = {
|
||||
@@ -21,4 +29,7 @@ def action():
|
||||
"schoolName": ask("Schule", args.school_name),
|
||||
}
|
||||
return client.request("POST", "/api/routes", fields=fields, files={"gpx": gpx})
|
||||
run(action)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(main)
|
||||
|
||||
Reference in New Issue
Block a user