Skip to content

Commit

Permalink
refact(export): add checks on input params
Browse files Browse the repository at this point in the history
  • Loading branch information
nlenglet-ign committed Oct 12, 2023
1 parent 85f9e7e commit 7df2531
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/export_graph/export_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def read_args():
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--cache", required=True, type=str, help="path of input cache")
parser.add_argument("-o", "--output", required=True, help="output folder")
parser.add_argument("-b", "--branch", required=True,
parser.add_argument("-b", "--branch", required=True, type=int,
help="id of branch of cache to use as source for patches")
parser.add_argument('-u', '--url',
help="http://[serveur]:[port] (default: http://localhost:8081)",
Expand All @@ -38,11 +38,21 @@ def read_args():
if args_prep.verbose >= 1:
print("\nArguments: ", args_prep)

# check input cache
if not os.path.exists(args_prep.cache):
raise SystemExit(f"ERROR: folder '{args_prep.cache}' does not exist")

# check branch -> voir create_qgis_view

# check input url
url_pattern = r'^https?:\/\/[0-9A-z.]+\:[0-9]+$'
if not re.match(url_pattern, args_prep.url):
raise SystemExit(f"ERROR: URL '{args_prep.url}' is invalid")

# check tilesize > 0
if args_prep.tilesize <= 0:
raise SystemExit("ERROR: tilesize must be greater that zero")

# check bbox
coords = str(args_prep.bbox).split(' ')
if any(elem is None for elem in coords) and any(elem is not None for elem in coords):
Expand Down

0 comments on commit 7df2531

Please sign in to comment.