Commit 17aa00c1 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Make executable scripts responsive to --version option

parent 3723f56d
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -29,7 +29,11 @@ import numpy as np

from sys import argv

## \brief Main execution code
## \cond
__version__ = "0.10.10"
## \endcond

## \brief Main execution code.
#
# `main()` is the function that handles the creation of the script configuration
# and the execution of the comparison. It returns an integer value corresponding
@@ -45,7 +49,9 @@ def main():
        print(ex)
        print("\nType \"./inertia.py --help\" to get more detailed help.")
        errors = 1
    if config['help_mode']:
    if config['version_mode']:
      print("inertia.py v%s."%__version__)
    elif config['help_mode']:
        config['help_mode'] = True
        print_help()
    else:
@@ -456,7 +462,8 @@ def parse_arguments():
        'scat_name': '',
        'geom_name': '',
        'specific': [1.0],
        'help_mode': False
        'help_mode': False,
        'version_mode': False
    }
    arg_index = 1
    skip_arg = False
@@ -482,6 +489,8 @@ def parse_arguments():
                config['specific'].append(float(vec_specifics[si]))
        elif (arg.startswith("--help")):
            config['help_mode'] = True
        elif (arg.startswith("--version")):
            config['version_mode'] = True
        else:
            raise ValueError("Unrecognized argument \'{0:s}\'".format(arg))
        arg_index += 1
@@ -501,6 +510,7 @@ def print_help():
    print("--geom GEOM              Geometry configuration file (mandatory).          ")
    print("--help                   Print this help and exit.                         ")
    print("--spew=SPEC_WEIGHT       Specific weight of materials (in g/cm3, optional).")
    print("--version                Print script version and exit.                    ")
    print("                                                                           ")

# ### PROGRAM EXECUTION ###
+13 −2
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@
import math
from sys import argv

## \cond
__version__ = "0.10.10"
## \endcond


## \brief Main execution code
#
# `main()` is the function that handles the creation of the script configuration
@@ -41,7 +46,9 @@ def main():
    errors = 0
    try:
        config = parse_arguments()
        if config['help_mode']:
        if config['version_mode']:
            print("pywiscombe.py v%s."%__version__)
        elif config['help_mode']:
            print_help()
        else:
            if (config['mode'] == ''):
@@ -83,7 +90,8 @@ def parse_arguments():
        'wavelength': 0.0,
        'radius': 0.0,
        'refraction' : 1.0,
        'help_mode': False
        'help_mode': False,
        'version_mode': False
    }
    arg_index = 1
    skip_arg = False
@@ -104,6 +112,8 @@ def parse_arguments():
            config['refraction'] = float(split_arg[1])
        elif (arg.startswith("--help")):
            config['help_mode'] = True
        elif (arg.startswith("--version")):
            config['version_mode'] = True
        else:
            raise ValueError("Unrecognized argument \'{0:s}\'".format(arg))
        arg_index += 1
@@ -124,6 +134,7 @@ def print_help():
    print("--wave=WAVELENGTH        Radiation wavelength in meters (mandatory).               ")
    print("--rad=RADIUS             Particle radius in meters (mandatory).                    ")
    print("--help                   Print this help and exit.                                 ")
    print("--version                Print script version and exit.                            ")
    print("                                                                                   ")

# ### PROGRAM EXECUTION ###
+9 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import re
from sys import argv

## \cond
__version__ = "0.10.10"
int_reg = re.compile(r'-?[0-9]+')
float_reg = re.compile(r'-?[0-9]+\.[0-9]+([eEdD][-+]?[0-9]+)?')
## \endcond
@@ -49,7 +50,9 @@ def main():
        print(ex)
        print("\nType \"scale_model.py --help\" to get more detailed help.")
        errors = 1
    if config['help_mode']:
    if config['version_mode']:
        print("scale_model.py v%s."%__version__)
    elif config['help_mode']:
        config['help_mode'] = True
        print_help()
    else:
@@ -92,7 +95,8 @@ def parse_arguments():
        'output_name': '',
        'mode': '',
        'scale': 1.0,
        'help_mode': False
        'help_mode': False,
        'version_mode': False
    }
    arg_index = 1
    skip_arg = False
@@ -115,6 +119,8 @@ def parse_arguments():
            config['scale'] = float(split_arg[1])
        elif (arg.startswith("--help")):
            config['help_mode'] = True
        elif (arg.startswith("--version")):
            config['version_mode'] = True
        else:
            raise ValueError("Unrecognized argument \'{0:s}\'".format(arg))
        arg_index += 1
@@ -272,6 +278,7 @@ def print_help():
    print("--mode=[edfb|geom]       Type of input to be processed (mandatory).        ")
    print("--scale=SCALE            Scale to be applied (optional, default is 1).     ")
    print("--help                   Print this help and exit.                         ")
    print("--version                Print script version and exit.                    ")
    print("                                                                           ")

# ### PROGRAM EXECUTION ###