def lookup_ubuntu_ami(table, release, stream, store, arch, region, virt):
 expected = (release, stream, store, arch, region, virt)
 for row in table:
  (actual_release, actual_stream, tag, serial, actual_store, actual_arch, actual_region, ami, aki, ari, actual_virt) = row
  actual = (actual_release, actual_stream, actual_store, actual_arch, actual_region, actual_virt)
  if (actual == expected):
   if (aki == ''):
    aki = None
   if (ari == ''):
    ari = None
   return (ami, aki, ari, tag, serial)
 raise KeyError()

def lookup_ubuntu_ami ( table , release , stream , store , arch , region , virt ) : expected = ( release , stream , store , arch , region , virt ) for row in table : ( actual_release , actual_stream , tag , serial , actual_store , actual_arch , actual_region , ami , aki , ari , actual_virt ) = row actual = ( actual_release , actual_stream , actual_store , actual_arch , actual_region , actual_virt ) if ( actual == expected ) : if ( aki == '' ) : aki = None if ( ari == '' ) : ari = None return ( ami , aki , ari , tag , serial ) raise KeyError ( )
look up the ubuntu ami that matches query given a table of amis table: an iterable that returns a row of release: ubuntu release name stream: server or desktop store: ebs .