Ejemplo n.º 1
0
def interleave_tileset(data):
    tile_size = 8*8

    tiles = []
    for planar_tile in take_n(data, tile_size):
        tiles.append(interleave_planar(planar_tile))
    return tiles
Ejemplo n.º 2
0
def flip_image(image, image_w, hflip=False, vflip=False):
    if not hflip and not vflip:
        return image

    rows = list(take_n(image, image_w))

    if vflip:
        rows.reverse()

    if hflip:
        for row in rows:
            row.reverse()

    # flatten list of arrays back
    return array('B', (pixel for row in rows for pixel in row))
Ejemplo n.º 3
0
def parse_objects(world_data, num_objects):
    objects_data = world_data[:num_objects * ObjectType.ENTRY_SIZE]

    return (ObjectType(obj_data) for obj_data in take_n(objects_data, ObjectType.ENTRY_SIZE))
Ejemplo n.º 4
0
def unpack_palette(data):
    pal = []
    for r,g,b in util.take_n(data, 3):
        pal.append((r, g, b))
    return pal
Ejemplo n.º 5
0
###########
# 16 hosts per /24
devices = fx.generate_devices(16 * len(networks))

# Create Device objects
site.devices.post(devices)
print 'Populated Devices.'


##############
# Interfaces #
##############
# Get list of device ids
dev_resp = site.devices.get()
device_ids = [dev['id'] for dev in dev_resp['data']['devices']]

# Get list of IP addreses and make them an iterable for take()
ip_list = [a['cidr'] for a in addresses]
ip_iter = iter(ip_list)

# 16 interfaces per host
interfaces = []
for device_id in device_ids:
    my_ips = fx.take_n(16, ip_iter)
    my_interfaces = fx.generate_interfaces(device_id, address_pool=my_ips)
    interfaces.extend(my_interfaces)

# Create Interface objects
site.interfaces.post(interfaces)
print 'Populated Interfaces.'