def _introspect_schema(self, raw_schema, raw_attributes=None): """ Given a raw schema structure back from a DynamoDB response, parse out & build the high-level Python objects that represent them. """ schema = [] sane_attributes = {} if raw_attributes: for field in raw_attributes: sane_attributes[field['AttributeName']] = field['AttributeType'] for field in raw_schema: data_type = sane_attributes.get(field['AttributeName'], STRING) if field['KeyType'] == 'HASH': schema.append( HashKey(field['AttributeName'], data_type=data_type) ) elif field['KeyType'] == 'RANGE': schema.append( RangeKey(field['AttributeName'], data_type=data_type) ) else: raise exceptions.UnknownSchemaFieldError( "%s was seen, but is unknown. Please report this at " "https://github.com/boto/boto/issues." % field['KeyType'] ) return schema
def introspect_schema(raw_schema, raw_attributes=None): """ Given a raw schema structure back from a DynamoDB response, parse out & build the high-level Python objects that represent them. """ schema = [] sane_attributes = {} if raw_attributes: for field in raw_attributes: sane_attributes[field['AttributeName']] = field['AttributeType'] key_name_to_class = {'HASH': HashKey, 'RANGE': RangeKey} for field in raw_schema: data_type = sane_attributes.get(field['AttributeName'], STRING) key_type_name = field['KeyType'] try: schema.append(key_name_to_class[key_type_name]( field['AttributeName'], data_type=data_type)) except KeyError: raise exceptions.UnknownSchemaFieldError( "%s was seen, but is unknown. Please report this at " "https://github.com/boto/boto/issues." % key_type_name) return schema