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
    try:
        arg_params['help'] = params_help[arg_name]
    except KeyError:
        pass
    if has_default:
        positional = False
    if default_value in (int, float):
        positional = True
    if default_value is True:
        arg_params['action'] = 'store_false'
    elif default_value is False:
        arg_params['action'] = 'store_true'
    if type(default_value) in (int, float):
        arg_params['type'] = type(default_value)
    if positional:
        if arg_name.startswith('_'):
            arg_params['nargs'] = '?'
            arg_params['default'] = None
            arg_params['metavar'] = 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
