<commit_before>BASE_IMAGE = 0x1
SNAPSHOT_IMAGE = 0x2
LINUX_IMAGE = 0x10

OS_UBUNTU = 0x100
OS_DEBIAN = 0x200
OS_CENTOS = 0x400
OS_RHEL = 0x800


def isset(num, flag):
    if not num:
        return False
    return num & flag > 0


flags = {'base' : BASE_IMAGE,
         'snapshot' : SNAPSHOT_IMAGE,
         'linux' : LINUX_IMAGE,
         'ubuntu' : OS_UBUNTU,
         'debian' : OS_DEBIAN,
         'centos' : OS_CENTOS,
         'rhel' : OS_RHEL}


def readable(num):
    result = []
    for k, v in flags.iteritems():
        if isset(num, v):
            result.append(k)
    return result


def get_numeric_code(payload, default=0):
    meta = payload.get('image_meta', {})
    if default == None:
        default = 0
    num = default

    image_type = meta.get('image_type', '')
    if image_type == 'base':
        num |= BASE_IMAGE
    if image_type == 'snapshot':
        num |= SNAPSHOT_IMAGE

    os_type = meta.get('os_type', payload.get('os_type', ''))
    if os_type == 'linux':
        num |= LINUX_IMAGE

    os_distro = meta.get('os_distro', '')
    if os_distro == 'ubuntu':
        num |= OS_UBUNTU
    if os_distro == 'debian':
        num |= OS_DEBIAN
    if os_distro == 'centos':
        num |= OS_CENTOS
    if os_distro == 'rhel':
        num |= OS_RHEL

    return num<commit_msg>added windows image to image_type.py and tests for image_type.py<commit_after>BASE_IMAGE = 0x1
SNAPSHOT_IMAGE = 0x2

LINUX_IMAGE = 0x10
WINDOWS_IMAGE = 0x20

OS_UBUNTU = 0x100
OS_DEBIAN = 0x200
OS_CENTOS = 0x400
OS_RHEL = 0x800


def isset(num, flag):
    if not num:
        return False
    return num & flag > 0


flags = {'base' : BASE_IMAGE,
         'snapshot' : SNAPSHOT_IMAGE,
         'linux' : LINUX_IMAGE,
         'windows': WINDOWS_IMAGE,
         'ubuntu' : OS_UBUNTU,
         'debian' : OS_DEBIAN,
         'centos' : OS_CENTOS,
         'rhel' : OS_RHEL}


def readable(num):
    result = []
    for k, v in flags.iteritems():
        if isset(num, v):
            result.append(k)
    return result


def get_numeric_code(payload, default=0):
    meta = payload.get('image_meta', {})
    if default == None:
        default = 0
    num = default

    image_type = meta.get('image_type', '')
    if image_type == 'base':
        num |= BASE_IMAGE
    if image_type == 'snapshot':
        num |= SNAPSHOT_IMAGE

    os_type = meta.get('os_type', payload.get('os_type', ''))
    if os_type == 'linux':
        num |= LINUX_IMAGE
    if os_type == 'windows':
        num |= WINDOWS_IMAGE

    os_distro = meta.get('os_distro', '')
    if os_distro == 'ubuntu':
        num |= OS_UBUNTU
    if os_distro == 'debian':
        num |= OS_DEBIAN
    if os_distro == 'centos':
        num |= OS_CENTOS
    if os_distro == 'rhel':
        num |= OS_RHEL

    return num
{'fraction_non_alphanumeric': 0.12419239052404882, 'fraction_numerical': 0.01974156496769562, 'mean_word_length': 2.3297491039426523, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5770337', 'n_tokens_mistral': 1085, 'n_tokens_neox': 1024, 'n_words': 238}