def check_gid(val):
    """Return a gid, given a group value

    If the group value is unknown, raises a ValueError.
    """

    if isinstance(val, int):
        try:
            grp.getgrgid(val)
            return val
        except (__HOLE__, OverflowError):
            raise ValueError("No such group: %r" % val)

    if not isinstance(val, str):
        raise TypeError(val)
    try:
        return grp.getgrnam(val).gr_gid
    except KeyError:
        raise ValueError("No such group: %r" % val)
dataset/ETHPy150Open benoitc/gaffer/gaffer/util.py/check_gid