From 8dedced1991e9bec321db1953f108058e77ccad8 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Mon, 6 Dec 2021 21:19:39 +0100
Subject: [PATCH] Allow the module to be imported

So we get the function without executing the rest.
---
 Inst_eddies/inst_eddies_in.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/Inst_eddies/inst_eddies_in.py b/Inst_eddies/inst_eddies_in.py
index 2862bd35..1f52acf2 100755
--- a/Inst_eddies/inst_eddies_in.py
+++ b/Inst_eddies/inst_eddies_in.py
@@ -84,13 +84,14 @@ def loop_inst_eddies(files, bbox, d):
     os.remove("unpacked.nc")
     if bbox: os.remove("cropped.nc")
 
-argparser = argparse.ArgumentParser()
-argparser.add_argument("file", nargs = "+",
-                       help = "NetCDF file containing SSH and velocity at a "
-                       "single date")
-argparser.add_argument("-b", "--bbox", nargs=4, type = float,
-                       metavar = ("xmin", "xmax", "ymin", "ymax"))
-args = argparser.parse_args()
-d = input("Enter first date (integer value):")
-d = int(d)
-loop_inst_eddies(args.file, args.bbox, d)
+if __name__ == "__main__":
+    argparser = argparse.ArgumentParser()
+    argparser.add_argument("file", nargs = "+",
+                           help = "NetCDF file containing SSH and velocity at a "
+                           "single date")
+    argparser.add_argument("-b", "--bbox", nargs=4, type = float,
+                           metavar = ("xmin", "xmax", "ymin", "ymax"))
+    args = argparser.parse_args()
+    d = input("Enter first date (integer value):")
+    d = int(d)
+    loop_inst_eddies(args.file, args.bbox, d)
-- 
GitLab