<s> """<STR_LIT>""" <EOL> import os , datetime <EOL> import cPickle as pickle <EOL> from . . import sg_timezone , ShotgunError <EOL> from . . shotgun import _Config <EOL> __version__ = "<STR_LIT>" <EOL> class MockgunError ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def generate_schema ( shotgun , schema_file_path , schema_entity_file_path ) : <EOL> """<STR_LIT>""" <EOL> schema = shotgun . schema_read ( ) <EOL> fh = open ( schema_file_path , "<STR_LIT:w>" ) <EOL> pickle . dump ( schema , fh ) <EOL> fh . close ( ) <EOL> schema_entity = shotgun . schema_entity_read ( ) <EOL> fh = open ( schema_entity_file_path , "<STR_LIT:w>" ) <EOL> pickle . dump ( schema_entity , fh ) <EOL> fh . close ( ) <EOL> class Shotgun ( object ) : <EOL> """<STR_LIT>""" <EOL> __schema_path = None <EOL> __schema_entity_path = None <EOL> @ classmethod <EOL> def set_schema_paths ( cls , schema_path , schema_entity_path ) : <EOL> """<STR_LIT>""" <EOL> cls . __schema_path = schema_path <EOL> cls . __schema_entity_path = schema_entity_path <EOL> @ classmethod <EOL> def get_schema_paths ( cls ) : <EOL> """<STR_LIT>""" <EOL> return ( cls . __schema_path , cls . __schema_entity_path ) <EOL> def __init__ ( self , <EOL> base_url , <EOL> script_name = None , <EOL> api_key = None , <EOL> convert_datetimes_to_utc = True , <EOL> http_proxy = None , <EOL> ensure_ascii = True , <EOL> connect = True , <EOL> ca_certs = None , <EOL> login = None , <EOL> password = None , <EOL> sudo_as_login = None , <EOL> session_token = None , <EOL> auth_token = None ) : <EOL> self . config = _Config ( ) <EOL> ( schema_path , schema_entity_path ) = self . get_schema_paths ( ) <EOL> if schema_path is None or schema_entity_path is None : <EOL> raise MockgunError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if not os . path . exists ( schema_path ) : <EOL> raise MockgunError ( "<STR_LIT>" % schema_path ) <EOL> if not os . path . exists ( schema_entity_path ) : <EOL> raise MockgunError ( "<STR_LIT>" % schema_entity_path ) <EOL> fh = open ( schema_path , "<STR_LIT:r>" ) <EOL> try : <EOL> self . _schema = pickle . load ( fh ) <EOL> finally : <EOL> fh . close ( ) <EOL> fh = open ( schema_entity_path , "<STR_LIT:r>" ) <EOL> try : <EOL> self . _schema_entity = pickle . load ( fh ) <EOL> finally : <EOL> fh . close ( ) <EOL> self . _db = dict ( ( entity , { } ) for entity in self . _schema ) <EOL> self . base_url = base_url <EOL> data = { } <EOL> data [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> data [ "<STR_LIT:description>" ] = "<STR_LIT>" <EOL> self . create ( "<STR_LIT>" , data ) <EOL> self . finds = <NUM_LIT:0> <EOL> def schema_read ( self ) : <EOL> return self . _schema <EOL> def schema_field_create ( self , entity_type , data_type , display_name , properties = None ) : <EOL> raise NotImplementedError <EOL> def schema_field_update ( self , entity_type , field_name , properties ) : <EOL> raise NotImplementedError <EOL> def schema_field_delete ( self , entity_type , field_name ) : <EOL> raise NotImplementedError <EOL> def schema_entity_read ( self ) : <EOL> return self . _schema_entity <EOL> def schema_field_read ( self , entity_type , field_name = None ) : <EOL> if field_name is None : <EOL> return self . _schema [ entity_type ] <EOL> else : <EOL> return dict ( ( k , v ) for k , v in self . _schema [ entity_type ] . items ( ) if k == field_name ) <EOL> def find ( self , entity_type , filters , fields = None , order = None , filter_operator = None , limit = <NUM_LIT:0> , retired_only = False , page = <NUM_LIT:0> ) : <EOL> self . finds += <NUM_LIT:1> <EOL> self . _validate_entity_type ( entity_type ) <EOL> if isinstance ( filters , dict ) : <EOL> resolved_filters = [ ] <EOL> for f in filters [ "<STR_LIT>" ] : <EOL> if f [ "<STR_LIT:path>" ] . startswith ( "<STR_LIT>" ) : <EOL> continue <EOL> if len ( f [ "<STR_LIT>" ] ) != <NUM_LIT:1> : <EOL> resolved_filters . append ( [ f [ "<STR_LIT:path>" ] , f [ "<STR_LIT>" ] , f [ "<STR_LIT>" ] ] ) <EOL> else : <EOL> resolved_filters . append ( [ f [ "<STR_LIT:path>" ] , f [ "<STR_LIT>" ] , f [ "<STR_LIT>" ] [ <NUM_LIT:0> ] ] ) <EOL> else : <EOL> resolved_filters = filters <EOL> resolved_filters_2 = [ ] <EOL> for f in resolved_filters : <EOL> if len ( f ) > <NUM_LIT:3> : <EOL> new_filter = [ f [ <NUM_LIT:0> ] , f [ <NUM_LIT:1> ] , f [ <NUM_LIT:2> : ] ] <EOL> elif f [ <NUM_LIT:1> ] == "<STR_LIT>" and not isinstance ( f [ <NUM_LIT:2> ] , list ) : <EOL> new_filter = [ f [ <NUM_LIT:0> ] , f [ <NUM_LIT:1> ] , [ f [ <NUM_LIT:2> ] ] ] <EOL> else : <EOL> new_filter = f <EOL> resolved_filters_2 . append ( new_filter ) <EOL> results = [ row for row in self . _db [ entity_type ] . values ( ) if self . _row_matches_filters ( entity_type , row , resolved_filters_2 , filter_operator , retired_only ) ] <EOL> if order : <EOL> for order_entry in order : <EOL> if "<STR_LIT>" not in order_entry : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> order_field = order_entry [ "<STR_LIT>" ] <EOL> if order_entry [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> desc_order = False <EOL> elif order_entry [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> desc_order = True <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> results = sorted ( results , key = lambda k : k [ order_field ] , reverse = desc_order ) <EOL> if fields is None : <EOL> fields = set ( [ "<STR_LIT:type>" , "<STR_LIT:id>" ] ) <EOL> else : <EOL> fields = set ( fields ) | set ( [ "<STR_LIT:type>" , "<STR_LIT:id>" ] ) <EOL> val = [ dict ( ( field , self . _get_field_from_row ( entity_type , row , field ) ) for field in fields ) for row in results ] <EOL> return val <EOL> def find_one ( self , entity_type , filters , fields = None , order = None , filter_operator = None , retired_only = False ) : <EOL> results = self . find ( entity_type , filters , fields = fields , order = order , filter_operator = filter_operator , retired_only = retired_only ) <EOL> return results [ <NUM_LIT:0> ] if results else None <EOL> def batch ( self , requests ) : <EOL> results = [ ] <EOL> for request in requests : <EOL> if request [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> results . append ( self . create ( request [ "<STR_LIT>" ] , request [ "<STR_LIT:data>" ] ) ) <EOL> elif request [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> results . append ( self . update ( request [ "<STR_LIT>" ] , request [ "<STR_LIT>" ] , request [ "<STR_LIT:data>" ] ) [ <NUM_LIT:0> ] ) <EOL> elif request [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> results . append ( self . delete ( request [ "<STR_LIT>" ] , request [ "<STR_LIT>" ] ) ) <EOL> else : <EOL> raise ShotgunError ( "<STR_LIT>" % ( request [ "<STR_LIT>" ] , request ) ) <EOL> return results <EOL> def create ( self , entity_type , data , return_fields = None ) : <EOL> for d in data : <EOL> if isinstance ( data [ d ] , dict ) and "<STR_LIT>" in data [ d ] : <EOL> if "<STR_LIT>" not in data [ d ] : <EOL> data [ d ] [ "<STR_LIT>" ] = { "<STR_LIT:id>" : <NUM_LIT:0> , "<STR_LIT:name>" : "<STR_LIT>" , "<STR_LIT:type>" : "<STR_LIT>" } <EOL> if "<STR_LIT>" not in data [ d ] : <EOL> data [ d ] [ "<STR_LIT>" ] = data [ d ] [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" not in data [ d ] : <EOL> data [ d ] [ "<STR_LIT>" ] = data [ d ] [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" not in data [ d ] : <EOL> data [ d ] [ "<STR_LIT>" ] = data [ d ] [ "<STR_LIT>" ] <EOL> self . _validate_entity_type ( entity_type ) <EOL> self . _validate_entity_data ( entity_type , data ) <EOL> self . _validate_entity_fields ( entity_type , return_fields ) <EOL> try : <EOL> next_id = max ( self . _db [ entity_type ] ) + <NUM_LIT:1> <EOL> except ValueError : <EOL> next_id = <NUM_LIT:1> <EOL> row = self . _get_new_row ( entity_type ) <EOL> self . _update_row ( entity_type , row , data ) <EOL> row [ "<STR_LIT:id>" ] = next_id <EOL> self . _db [ entity_type ] [ next_id ] = row <EOL> if return_fields is None : <EOL> result = dict ( ( field , self . _get_field_from_row ( entity_type , row , field ) ) for field in data ) <EOL> else : <EOL> result = dict ( ( field , self . _get_field_from_row ( entity_type , row , field ) ) for field in return_fields ) <EOL> result [ "<STR_LIT:type>" ] = row [ "<STR_LIT:type>" ] <EOL> result [ "<STR_LIT:id>" ] = row [ "<STR_LIT:id>" ] <EOL> return result <EOL> def update ( self , entity_type , entity_id , data ) : <EOL> self . _validate_entity_type ( entity_type ) <EOL> self . _validate_entity_data ( entity_type , data ) <EOL> self . _validate_entity_exists ( entity_type , entity_id ) <EOL> row = self . _db [ entity_type ] [ entity_id ] <EOL> self . _update_row ( entity_type , row , data ) <EOL> return [ dict ( ( field , item ) for field , item in row . items ( ) if field in data or field in ( "<STR_LIT:type>" , "<STR_LIT:id>" ) ) ] <EOL> def delete ( self , entity_type , entity_id ) : <EOL> self . _validate_entity_type ( entity_type ) <EOL> self . _validate_entity_exists ( entity_type , entity_id ) <EOL> row = self . _db [ entity_type ] [ entity_id ] <EOL> if not row [ "<STR_LIT>" ] : <EOL> row [ "<STR_LIT>" ] = True <EOL> return True <EOL> else : <EOL> return False <EOL> def revive ( self , entity_type , entity_id ) : <EOL> self . _validate_entity_type ( entity_type ) <EOL> self . _validate_entity_exists ( entity_type , entity_id ) <EOL> row = self . _db [ entity_type ] [ entity_id ] <EOL> if row [ "<STR_LIT>" ] : <EOL> row [ "<STR_LIT>" ] = False <EOL> return True <EOL> else : <EOL> return False <EOL> def upload ( self , entity_type , entity_id , path , field_name = None , display_name = None , tag_list = None ) : <EOL> raise NotImplementedError <EOL> def upload_thumbnail ( self , entity_type , entity_id , path , ** kwargs ) : <EOL> pass <EOL> def _validate_entity_type ( self , entity_type ) : <EOL> if entity_type not in self . _schema : <EOL> raise ShotgunError ( "<STR_LIT>" % entity_type ) <EOL> def _validate_entity_data ( self , entity_type , data ) : <EOL> if "<STR_LIT:id>" in data or "<STR_LIT:type>" in data : <EOL> raise ShotgunError ( "<STR_LIT>" ) <EOL> self . _validate_entity_fields ( entity_type , data . keys ( ) ) <EOL> for field , item in data . items ( ) : <EOL> if item is None : <EOL> continue <EOL> field_info = self . _schema [ entity_type ] [ field ] <EOL> if field_info [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] == "<STR_LIT>" : <EOL> if not isinstance ( item , list ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , item ) ) <EOL> elif item and any ( not isinstance ( sub_item , dict ) for sub_item in item ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , item ) ) <EOL> elif item and any ( "<STR_LIT:id>" not in sub_item or "<STR_LIT:type>" not in sub_item for sub_item in item ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , item ) ) <EOL> elif item and any ( sub_item [ "<STR_LIT:type>" ] not in field_info [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] for sub_item in item ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , item , field_info [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] ) ) <EOL> elif field_info [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] == "<STR_LIT>" : <EOL> if not isinstance ( item , dict ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , item ) ) <EOL> elif "<STR_LIT:id>" not in item or "<STR_LIT:type>" not in item : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , item ) ) <EOL> else : <EOL> try : <EOL> sg_type = field_info [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] <EOL> python_type = { "<STR_LIT>" : int , <EOL> "<STR_LIT:float>" : float , <EOL> "<STR_LIT>" : bool , <EOL> "<STR_LIT:text>" : basestring , <EOL> "<STR_LIT>" : dict , <EOL> "<STR_LIT:date>" : datetime . date , <EOL> "<STR_LIT>" : datetime . datetime , <EOL> "<STR_LIT:url>" : dict } [ sg_type ] <EOL> except KeyError : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , sg_type ) ) <EOL> if not isinstance ( item , python_type ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field , type ( item ) , sg_type , python_type ) ) <EOL> def _validate_entity_fields ( self , entity_type , fields ) : <EOL> self . _validate_entity_type ( entity_type ) <EOL> if fields is not None : <EOL> valid_fields = set ( self . _schema [ entity_type ] . keys ( ) ) <EOL> for field in fields : <EOL> try : <EOL> field2 , entity_type2 , field3 = field . split ( "<STR_LIT:.>" , <NUM_LIT:2> ) <EOL> self . _validate_entity_fields ( entity_type2 , [ field3 ] ) <EOL> except ValueError : <EOL> if field not in valid_fields and field not in ( "<STR_LIT:type>" , "<STR_LIT:id>" ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( field , entity_type ) ) <EOL> def _get_default_value ( self , entity_type , field ) : <EOL> field_info = self . _schema [ entity_type ] [ field ] <EOL> if field_info [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] == "<STR_LIT>" : <EOL> default_value = [ ] <EOL> else : <EOL> default_value = field_info [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] <EOL> return default_value <EOL> def _get_new_row ( self , entity_type ) : <EOL> row = { "<STR_LIT:type>" : entity_type , "<STR_LIT>" : False } <EOL> for field in self . _schema [ entity_type ] : <EOL> field_info = self . _schema [ entity_type ] [ field ] <EOL> if field_info [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] == "<STR_LIT>" : <EOL> default_value = [ ] <EOL> else : <EOL> default_value = field_info [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] <EOL> row [ field ] = default_value <EOL> return row <EOL> def _compare ( self , field_type , lval , operator , rval ) : <EOL> if field_type == "<STR_LIT>" : <EOL> if operator == "<STR_LIT>" : <EOL> return lval == rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval != rval <EOL> elif field_type in ( "<STR_LIT:float>" , "<STR_LIT>" , "<STR_LIT:date>" , "<STR_LIT>" ) : <EOL> if operator == "<STR_LIT>" : <EOL> return lval == rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval != rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval < rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval > rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval >= rval [ <NUM_LIT:0> ] and lval <= rval [ <NUM_LIT:1> ] <EOL> elif operator == "<STR_LIT>" : <EOL> return lval < rval [ <NUM_LIT:0> ] or lval > rval [ <NUM_LIT:1> ] <EOL> elif operator == "<STR_LIT>" : <EOL> return lval in rval <EOL> elif field_type == "<STR_LIT:list>" : <EOL> if operator == "<STR_LIT>" : <EOL> return lval == rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval != rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval in rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval not in rval <EOL> elif field_type == "<STR_LIT>" : <EOL> if operator == "<STR_LIT>" : <EOL> return lval == rval <EOL> elif field_type == "<STR_LIT:text>" : <EOL> if operator == "<STR_LIT>" : <EOL> return lval == rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval != rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval in rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval in rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval not in rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval . startswith ( rval ) <EOL> elif operator == "<STR_LIT>" : <EOL> return lval . endswith ( rval ) <EOL> elif field_type == "<STR_LIT>" : <EOL> if operator == "<STR_LIT>" : <EOL> return lval [ "<STR_LIT:type>" ] == rval [ "<STR_LIT:type>" ] and lval [ "<STR_LIT:id>" ] == rval [ "<STR_LIT:id>" ] <EOL> elif operator == "<STR_LIT>" : <EOL> return lval [ "<STR_LIT:type>" ] != rval [ "<STR_LIT:type>" ] or lval [ "<STR_LIT:id>" ] != rval [ "<STR_LIT:id>" ] <EOL> elif operator == "<STR_LIT>" : <EOL> return all ( ( lval [ "<STR_LIT:type>" ] == sub_rval [ "<STR_LIT:type>" ] and lval [ "<STR_LIT:id>" ] == sub_rval [ "<STR_LIT:id>" ] ) for sub_rval in rval ) <EOL> elif operator == "<STR_LIT>" : <EOL> return lval [ "<STR_LIT:type>" ] == rval <EOL> elif operator == "<STR_LIT>" : <EOL> return lval [ "<STR_LIT:type>" ] != rval <EOL> elif operator == "<STR_LIT>" : <EOL> return rval in lval [ "<STR_LIT:name>" ] <EOL> elif operator == "<STR_LIT>" : <EOL> return rval not in lval [ "<STR_LIT:name>" ] <EOL> elif operator == "<STR_LIT>" : <EOL> return lval [ "<STR_LIT:name>" ] . startswith ( rval ) <EOL> elif operator == "<STR_LIT>" : <EOL> return lval [ "<STR_LIT:name>" ] . endswith ( rval ) <EOL> elif field_type == "<STR_LIT>" : <EOL> if operator == "<STR_LIT>" : <EOL> return rval [ "<STR_LIT:id>" ] in ( sub_lval [ "<STR_LIT:id>" ] for sub_lval in lval ) <EOL> elif operator == "<STR_LIT>" : <EOL> return rval [ "<STR_LIT:id>" ] not in ( sub_lval [ "<STR_LIT:id>" ] for sub_lval in lval ) <EOL> raise ShotgunError ( "<STR_LIT>" % ( operator , field_type ) ) <EOL> def _get_field_from_row ( self , entity_type , row , field ) : <EOL> try : <EOL> field2 , entity_type2 , field3 = field . split ( "<STR_LIT:.>" , <NUM_LIT:2> ) <EOL> if field2 in row : <EOL> field_value = row [ field2 ] <EOL> if not isinstance ( field_value , dict ) : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , field ) ) <EOL> if entity_type2 != field_value [ "<STR_LIT:type>" ] : <EOL> raise ShotgunError ( "<STR_LIT>" <EOL> "<STR_LIT>" % ( entity_type , field , field_value ) ) <EOL> linked_row = self . _db [ field_value [ "<STR_LIT:type>" ] ] [ field_value [ "<STR_LIT:id>" ] ] <EOL> if field3 in linked_row : <EOL> return linked_row [ field3 ] <EOL> else : <EOL> return None <EOL> else : <EOL> return None <EOL> except ValueError : <EOL> if field in row : <EOL> return row [ field ] <EOL> else : <EOL> return None <EOL> def _get_field_type ( self , entity_type , field ) : <EOL> try : <EOL> field2 , entity_type2 , field3 = field . split ( "<STR_LIT:.>" , <NUM_LIT:2> ) <EOL> return self . _get_field_type ( entity_type2 , field3 ) <EOL> except ValueError : <EOL> return self . _schema [ entity_type ] [ field ] [ "<STR_LIT>" ] [ "<STR_LIT:value>" ] <EOL> def _row_matches_filter ( self , entity_type , row , filter ) : <EOL> try : <EOL> field , operator , rval = filter <EOL> except ValueError : <EOL> raise ShotgunError ( "<STR_LIT>" ) <EOL> lval = self . _get_field_from_row ( entity_type , row , field ) <EOL> field_type = self . _get_field_type ( entity_type , field ) <EOL> if field_type == "<STR_LIT>" : <EOL> lval_row = self . _db [ lval [ "<STR_LIT:type>" ] ] [ lval [ "<STR_LIT:id>" ] ] <EOL> if "<STR_LIT:name>" in lval_row : <EOL> lval [ "<STR_LIT:name>" ] = lval_row [ "<STR_LIT:name>" ] <EOL> elif "<STR_LIT:code>" in lval_row : <EOL> lval [ "<STR_LIT:name>" ] = lval_row [ "<STR_LIT:code>" ] <EOL> return self . _compare ( field_type , lval , operator , rval ) <EOL> def _row_matches_filters ( self , entity_type , row , filters , filter_operator , retired_only ) : <EOL> if retired_only and not row [ "<STR_LIT>" ] or not retired_only and row [ "<STR_LIT>" ] : <EOL> return False <EOL> elif filter_operator in ( "<STR_LIT:all>" , None ) : <EOL> return all ( self . _row_matches_filter ( entity_type , row , filter ) for filter in filters ) <EOL> elif filter_operator == "<STR_LIT>" : <EOL> return any ( self . _row_matches_filter ( entity_type , row , filter ) for filter in filters ) <EOL> else : <EOL> raise ShotgunError ( "<STR_LIT>" % filter_operator ) <EOL> def _update_row ( self , entity_type , row , data ) : <EOL> for field in data : <EOL> field_type = self . _get_field_type ( entity_type , field ) <EOL> if field_type == "<STR_LIT>" and data [ field ] : <EOL> row [ field ] = { "<STR_LIT:type>" : data [ field ] [ "<STR_LIT:type>" ] , "<STR_LIT:id>" : data [ field ] [ "<STR_LIT:id>" ] } <EOL> elif field_type == "<STR_LIT>" : <EOL> row [ field ] = [ { "<STR_LIT:type>" : item [ "<STR_LIT:type>" ] , "<STR_LIT:id>" : item [ "<STR_LIT:id>" ] } for item in data [ field ] ] <EOL> else : <EOL> row [ field ] = data [ field ] <EOL> def _validate_entity_exists ( self , entity_type , entity_id ) : <EOL> if entity_id not in self . _db [ entity_type ] : <EOL> raise ShotgunError ( "<STR_LIT>" % ( entity_type , entity_id ) ) </s>
