def CSVofIntegers(msg=None):
    '''
    Checks whether a value is list of integers.
    Returns list of integers or just an integer
    if there is only one element in list.
    '''
    def fn(value):
        try:
            if isinstance(value, unicode):
                if ',' in value:
                    value = map(int, filter(bool, value.split(',')))
                    return value
                else:
                    return int(value)
        except ValueError:
            raise Invalid(
                '<{0}> is not a valid csv of integers'.format(value)
            )
    return fn
dataset/ETHPy150Open manjitkumar/drf-url-filters/filters/validations.py/CSVofIntegers/original