Styling changes to CLI script.

Wed, 06 Dec 2017 11:50:30 +0200

author
Iannis <ulalume3@yahoo.com>
date
Wed, 06 Dec 2017 11:50:30 +0200
changeset 90
e2088d39ee9b
parent 86
cefef866804c
child 91
f9d9d3ea8edb

Styling changes to CLI script.

atmospheric_lidar/scripts/licel2scc.py file | annotate | diff | comparison | revisions
--- a/atmospheric_lidar/scripts/licel2scc.py	Fri Nov 10 10:21:45 2017 +0200
+++ b/atmospheric_lidar/scripts/licel2scc.py	Wed Dec 06 11:50:30 2017 +0200
@@ -109,6 +109,7 @@
 
     #coloredlogs.install(fmt='%(levelname)s: %(message)s', level=args.loglevel)
 
+    # Check for version
     if args.version:
         print("Version: %s" % __version__)
         sys.exit(0)
@@ -116,33 +117,36 @@
     # Get a list of files to convert
     files = glob.glob(args.files)
 
-    if files:
-        # Read the files
-        logger.info("Reading {0} files from {1}".format(len(files), os.path.abspath(os.path.dirname(args.files))))
-        CustomLidarMeasurement = create_custom_class(args.parameter_file, args.id_as_name, args.temperature,
-                                                     args.pressure)
-        measurement = CustomLidarMeasurement(files)
-        
-        # Get a list of files containing dark measurements
-        if args.dark_files != "":
-            dark_files = glob.glob (args.dark_files)
-            
-            if dark_files:
-                logger.debug("Using %s as dark measurements files!" % ', '.join(dark_files))
-                measurement.dark_measurement = CustomLidarMeasurement(dark_files)
-            else:
-                logger.warning('No dark measurement files found when searching for %s. Will not use any dark measurements.' % args.dark_files)
-        
-        try:
-            measurement = measurement.subset_by_scc_channels()
-        except ValueError as err:
-            logging.error(err)
-            sys.exit(1)
-        # Save the netcdf
-        logger.info("Saving netcdf")
-        measurement.set_measurement_id(args.measurement_id, args.measurement_number)
-        measurement.save_as_netcdf()
-        logger.info("Created file %s" % measurement.scc_filename)
-    else:
-        logger.error("No files found when searching for %s." % search_str)
-        sys.exit(1)
\ No newline at end of file
+    # If not files found, exit
+    if len(files) == 0:
+        logger.error("No files found when searching for %s." % args.files)
+        sys.exit(1)
+
+    # If everything OK, proceed
+    logger.info("Found {0} files matching {1}".format(len(files), os.path.abspath(args.files)))
+    CustomLidarMeasurement = create_custom_class(args.parameter_file, args.id_as_name, args.temperature,
+                                                 args.pressure)
+    measurement = CustomLidarMeasurement(files)
+
+    # Get a list of files containing dark measurements
+    if args.dark_files != "":
+        dark_files = glob.glob(args.dark_files)
+
+        if dark_files:
+            logger.debug("Using %s as dark measurements files!" % ', '.join(dark_files))
+            measurement.dark_measurement = CustomLidarMeasurement(dark_files)
+        else:
+            logger.warning('No dark measurement files found when searching for %s. Will not use any dark measurements.' % args.dark_files)
+
+    try:
+        measurement = measurement.subset_by_scc_channels()
+    except ValueError as err:
+        logging.error(err)
+        sys.exit(1)
+
+    # Save the netcdf
+    logger.info("Saving netcdf")
+    measurement.set_measurement_id(args.measurement_id, args.measurement_number)
+    measurement.save_as_netcdf()
+    logger.info("Created file %s" % measurement.scc_filename)
+

mercurial