This function looks at the default value and returns the type that
       should be supplied to the parser

def calculate_default_type(arg, has_default, default_value, params_help):
    """This function looks at the default value and returns the type that
       should be supplied to the parser"""
    positional = True
    arg_params = {}
    arg_name = arg

    # Check to see if we have help text for this argument
    try:
        arg_params['help'] = params_help[arg_name]
    except KeyError:
        pass

    # If we have a default value, then this is not positional
    if has_default:
        positional = False

    # Special case when a base type is supplied
    if default_value in (int, float):
        positional = True

    # For boolean options, change the action
    if default_value is True:
        arg_params['action'] = 'store_false'
    elif default_value is False:
        arg_params['action'] = 'store_true'

    # Finally, check if the default value is an integer or a float
    # and set the arg type on the item
    if type(default_value) in (int, float):
        arg_params['type'] = type(default_value)

    # Update the arg_name
    if positional:
        if arg_name.startswith('_'):
            arg_params['nargs'] = '?'
            arg_params['default'] = None
            arg_params['metavar'] = arg_name.lstrip('_')
            #arg_name = arg_name.lstrip('_')
    else:
        arg_params['default'] = default_value
        if len(arg_name) == 1:
            arg_name = '-' + arg_name
        else:
            arg_name = '--' + arg_name

    return arg_name, arg_params