'Parses the given int argument, limiting it to the given range.
Args:
name: the name of the argument
min_value: the minimum int value of the argument (if any)
max_value: the maximum int value of the argument (if any)
default: the default value of the argument if it is not given
Returns:
An int within the given range for the argument'

def get_range(self, name, min_value=None, max_value=None, default=0):

    value = self.get(name, default)
    if (value is None):
        return value
    try:
        value = int(value)
    except ValueError:
        value = default
    if (value is not None):
        if (max_value is not None):
            value = min(value, max_value)
        if (min_value is not None):
            value = max(value, min_value)
    return value
