nappy/script/na2nc.py
def parseArgs(args):
    """
    Parses arguments and returns dictionary.
    """
    arg_dict = {}
    a = arg_dict

    # Set up defaults
    a["na_file"] = None
    a["mode"] = "w"
    a["variables"] = "all"
    a["aux_variables"]  = "all"
    a["global_attributes"] = {}
    a["rename_variables"] = {}
    a["time_units"] = None
    a["time_warning"] = True
    a["nc_file"] = None

    try:
        (arg_list, dummy) = getopt.getopt(args, "i:o:m:v:a:g:t:nr:")
    except getopt.GetoptError, e:
        exitNicely(str(e))
    
    for arg, value in arg_list:
        if arg == "-i":
            a["na_file"] = value
        elif arg == "-o":
            a["nc_file"] = value
        elif arg == "-m":
            a["mode"] = value
        elif arg == "-v":
            a["variables"] = value.split(",")
            exitNicely("OPTION NOT IMPLEMENTED: %s : Not yet fully functional. Sorry." % arg)
        elif arg == "-a":
            a["aux_variables"] = value.split(",")
            exitNicely("OPTION NOT IMPLEMENTED: %s : Not yet fully functional. Sorry." % arg)
        elif arg == "-g":
            a["global_attributes"] = makeListFromCommaSepString(value)
        elif arg == "-t":
            a["time_units"] = value
        elif arg == "-n":
            a["time_warning"] = False
        elif arg == "-r":
            a["rename_variables"] = makeDictFromCommaSepString(value)
        else:
            exitNicely("Argument '" + arg + "' not recognised!")

    if not a["na_file"]:
        exitNicely("Please provide argument '-i <na_file>'")

    if not a["nc_file"]:
        fn = a["na_file"]
        if fn[-3:] == ".na": fn = fn[:-3]
        nc_file = fn + ".nc"
        print "Auto-generating output file name:", nc_file
        a["nc_file"] = nc_file

    return a

    Parses arguments and returns dictionary.
    
Parses arguments and returns dictionary.
Parses arguments and returns dictionary .
def parseArgs(args):
    arg_dict = {}
    a = arg_dict
    a["na_file"] = None
    a["mode"] = "w"
    a["variables"] = "all"
    a["aux_variables"]  = "all"
    a["global_attributes"] = {}
    a["rename_variables"] = {}
    a["time_units"] = None
    a["time_warning"] = True
    a["nc_file"] = None
    try:
        (arg_list, dummy) = getopt.getopt(args, "i:o:m:v:a:g:t:nr:")
    except getopt.GetoptError, e:
        exitNicely(str(e))
    for arg, value in arg_list:
        if arg == "-i":
            a["na_file"] = value
        elif arg == "-o":
            a["nc_file"] = value
        elif arg == "-m":
            a["mode"] = value
        elif arg == "-v":
            a["variables"] = value.split(",")
            exitNicely("OPTION NOT IMPLEMENTED: %s : Not yet fully functional. Sorry." % arg)
        elif arg == "-a":
            a["aux_variables"] = value.split(",")
            exitNicely("OPTION NOT IMPLEMENTED: %s : Not yet fully functional. Sorry." % arg)
        elif arg == "-g":
            a["global_attributes"] = makeListFromCommaSepString(value)
        elif arg == "-t":
            a["time_units"] = value
        elif arg == "-n":
            a["time_warning"] = False
        elif arg == "-r":
            a["rename_variables"] = makeDictFromCommaSepString(value)
        else:
            exitNicely("Argument '" + arg + "' not recognised!")
    if not a["na_file"]:
        exitNicely("Please provide argument '-i <na_file>'")
    if not a["nc_file"]:
        fn = a["na_file"]
        if fn[-3:] == ".na": fn = fn[:-3]
        nc_file = fn + ".nc"
        print "Auto-generating output file name:", nc_file
        a["nc_file"] = nc_file
    return a
def parseArgs ( args ) : arg_dict = { } a = arg_dict a [ "na_file" ] = None a [ "mode" ] = "w" a [ "variables" ] = "all" a [ "aux_variables" ] = "all" a [ "global_attributes" ] = { } a [ "rename_variables" ] = { } a [ "time_units" ] = None a [ "time_warning" ] = True a [ "nc_file" ] = None try : ( arg_list , dummy ) = getopt . getopt ( args , "i:o:m:v:a:g:t:nr:" ) except getopt . GetoptError , e : exitNicely ( str ( e ) ) for arg , value in arg_list : if arg == "-i" : a [ "na_file" ] = value elif arg == "-o" : a [ "nc_file" ] = value elif arg == "-m" : a [ "mode" ] = value elif arg == "-v" : a [ "variables" ] = value . split ( "," ) exitNicely ( "OPTION NOT IMPLEMENTED: %s : Not yet fully functional. Sorry." % arg ) elif arg == "-a" : a [ "aux_variables" ] = value . split ( "," ) exitNicely ( "OPTION NOT IMPLEMENTED: %s : Not yet fully functional. Sorry." % arg ) elif arg == "-g" : a [ "global_attributes" ] = makeListFromCommaSepString ( value ) elif arg == "-t" : a [ "time_units" ] = value elif arg == "-n" : a [ "time_warning" ] = False elif arg == "-r" : a [ "rename_variables" ] = makeDictFromCommaSepString ( value ) else : exitNicely ( "Argument '" + arg + "' not recognised!" ) if not a [ "na_file" ] : exitNicely ( "Please provide argument '-i <na_file>'" ) if not a [ "nc_file" ] : fn = a [ "na_file" ] if fn [ - 3 : ] == ".na" : fn = fn [ : - 3 ] nc_file = fn + ".nc" print "Auto-generating output file name:" , nc_file a [ "nc_file" ] = nc_file return a
Parses arguments and returns dictionary.
Parses arguments and returns dictionary .
"""
    Parses arguments and returns dictionary.
    """ # Set up defaults
args