def parse_rangestring(rangestring):
    """
    Parses a string that represents a range of numbers
    such as 1-4 or 1 or 1,3 or combinations such as
    1-3,5,7,8-10

    .. code-block:: python

        >>> from pypbs import util
        >>> util.parse_rangestring('1-3,5,7,8-10')
        [1, 2, 3, 5, 7, 8, 9, 10]

    :param str rangestring: range string to parse
    :returns: list of all numbers in range
    """
    if not rangestring:
        return []
    _range = []
    parts = rangestring.split(',')
    for part in parts:
        if '-' in part:
            s, e = part.split('-')
            for i in range(int(s), int(e) + 1):
                _range.append(i)
        else:
            _range.append(int(part))
    return _range
