def _convert2int(value, map, low, high, name, cmd):
    """private converter tries map(value) low<=int(value)<=high or finally an error"""
    try:
        return map[value]
    except KeyError:
        try:
            ivalue = int(value)
            if low <= ivalue <= high:
                return ivalue
        except:
            pass
    raise ValueError('Bad %s value %s in %s' % (name, value, ascii(cmd)))
