<s> import boto <EOL> import six <EOL> class FieldLists ( ) : <EOL> ADDRESS = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> BLOCK_DEVICE_TYPE = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:size>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:status>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> BUCKET = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:name>' <EOL> ] <EOL> EC2ZONE = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:name>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:state>' <EOL> ] <EOL> INSTANCE = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:state>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> RECORD = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:name>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:type>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> R53ZONE = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT:name>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> R53STATUS = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT:status>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> VOLUME = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:size>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:status>' , <EOL> '<STR_LIT:type>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> TAG = [ <EOL> '<STR_LIT:name>' , <EOL> '<STR_LIT:value>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> STACK = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:description>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> DBINSTANCE = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:id>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:status>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> class ResultSets ( object ) : <EOL> def __init__ ( self ) : <EOL> self . foo = '<STR_LIT>' <EOL> def selector ( self , output ) : <EOL> if isinstance ( output , boto . ec2 . instance . Reservation ) : <EOL> return self . parseReservation ( output ) <EOL> elif isinstance ( output , boto . ec2 . instance . Instance ) : <EOL> return self . parseInstance ( output ) <EOL> elif isinstance ( output , boto . ec2 . volume . Volume ) : <EOL> return self . parseVolume ( output ) <EOL> elif isinstance ( output , boto . ec2 . blockdevicemapping . BlockDeviceType ) : <EOL> return self . parseBlockDeviceType ( output ) <EOL> elif isinstance ( output , boto . ec2 . zone . Zone ) : <EOL> return self . parseEC2Zone ( output ) <EOL> elif isinstance ( output , boto . ec2 . address . Address ) : <EOL> return self . parseAddress ( output ) <EOL> elif isinstance ( output , boto . route53 . record . Record ) : <EOL> return self . parseRecord ( output ) <EOL> elif isinstance ( output , boto . route53 . zone . Zone ) : <EOL> return self . parseR53Zone ( output ) <EOL> elif isinstance ( output , boto . route53 . status . Status ) : <EOL> return self . parseR53Status ( output ) <EOL> elif isinstance ( output , boto . ec2 . tag . Tag ) : <EOL> return self . parseTag ( output ) <EOL> elif isinstance ( output , boto . ec2 . ec2object . EC2Object ) : <EOL> return self . parseEC2Object ( output ) <EOL> elif isinstance ( output , boto . cloudformation . stack . Stack ) : <EOL> return self . parseStackObject ( output ) <EOL> elif isinstance ( output , boto . rds . dbinstance . DBInstance ) : <EOL> return self . parseDBInstanceObject ( output ) <EOL> else : <EOL> return output <EOL> def formatter ( self , output ) : <EOL> if isinstance ( output , list ) : <EOL> return [ self . formatter ( item ) for item in output ] <EOL> elif isinstance ( output , dict ) : <EOL> return { key : self . formatter ( value ) for key , value in six . iteritems ( output ) } <EOL> else : <EOL> return self . selector ( output ) <EOL> def parseReservation ( self , output ) : <EOL> instance_list = [ ] <EOL> for instance in output . instances : <EOL> instance_data = self . parseInstance ( instance ) <EOL> instance_data [ '<STR_LIT>' ] = output . owner_id <EOL> instance_list . append ( instance_data ) <EOL> return instance_list <EOL> def parseAddress ( self , output ) : <EOL> instance_data = { field : getattr ( output , field ) for field in FieldLists . ADDRESS } <EOL> return instance_data <EOL> def parseInstance ( self , output ) : <EOL> instance_data = { field : getattr ( output , field ) for field in FieldLists . INSTANCE } <EOL> return instance_data <EOL> def parseVolume ( self , output ) : <EOL> volume_data = { field : getattr ( output , field ) for field in FieldLists . VOLUME } <EOL> return volume_data <EOL> def parseBlockDeviceType ( self , output ) : <EOL> data = { field : getattr ( output , field ) for field in FieldLists . BLOCK_DEVICE_TYPE } <EOL> return data <EOL> def parseEC2Zone ( self , output ) : <EOL> zone_data = { field : getattr ( output , field ) for field in FieldLists . EC2ZONE } <EOL> return zone_data <EOL> def parseRecord ( self , output ) : <EOL> record_data = { field : getattr ( output , field ) for field in FieldLists . RECORD } <EOL> return record_data <EOL> def parseR53Zone ( self , output ) : <EOL> zone_data = { field : getattr ( output , field ) for field in FieldLists . R53ZONE } <EOL> return zone_data <EOL> def parseR53Status ( self , output ) : <EOL> status_data = { field : getattr ( output , field ) for field in FieldLists . R53STATUS } <EOL> return status_data <EOL> def parseBucket ( self , output ) : <EOL> bucket_data = { field : getattr ( output , field ) for field in FieldLists . BUCKET } <EOL> return bucket_data <EOL> def parseTag ( self , output ) : <EOL> tag_data = { field : getattr ( output , field ) for field in FieldLists . TAG } <EOL> return tag_data <EOL> def parseStackObject ( self , output ) : <EOL> stack_data = { field : getattr ( output , field ) for field in FieldLists . STACK } <EOL> return stack_data <EOL> def parseDBInstanceObject ( self , output ) : <EOL> dbinstance_data = { field : getattr ( output , field ) for field in FieldLists . DBINSTANCE } <EOL> return dbinstance_data <EOL> def parseEC2Object ( self , output ) : <EOL> output = vars ( output ) <EOL> del output [ '<STR_LIT>' ] <EOL> region = output . get ( '<STR_LIT>' , None ) <EOL> output [ '<STR_LIT>' ] = region . name if region else '<STR_LIT>' <EOL> for k , v in six . iteritems ( output ) : <EOL> if isinstance ( v , boto . ec2 . ec2object . EC2Object ) : <EOL> output [ k ] = getattr ( v , '<STR_LIT:id>' , str ( v ) ) <EOL> if isinstance ( v , list ) : <EOL> v_list = [ ] <EOL> for item in v : <EOL> if isinstance ( item , ( basestring , bool , int , long , float ) ) : <EOL> v_list . append ( v ) <EOL> else : <EOL> v_list . append ( str ( item ) ) <EOL> output [ k ] = v_list <EOL> return output </s>
