#NEWLINE# def create_deep_key( * path_info ) : #NEWLINE# #INDENT# "A method to make multi-level Key objects.\n\n  Generates multi-level key from multiple fields in the input dictionary.\n\n  This is typically used for Keys for entities which have variable parent keys,\n  e.g. ones with owned relationships. It can used for both __key__ and\n  references.\n\n  Use create_foreign_key as a simpler way to create single level keys.\n\n  Args:\n    path_info: List of tuples, describing (kind, property, is_id=False).\n      kind: The kind name.\n      property: The external property in the current import dictionary, or\n        transform.CURRENT_PROPERTY for the value passed to the transform.\n      is_id: Converts value to int and treats as numeric ID if True, otherwise\n        the value is a string name. Default is False.\n      Example:\n        create_deep_key(('rootkind', 'rootcolumn'),\n                        ('childkind', 'childcolumn', True),\n                        ('leafkind', transform.CURRENT_PROPERTY))\n\n  Returns:\n    Transform method which parses the info from the current neutral dictionary\n    into a Key with parents as described by path_info.\n  " #NEWLINE# validated_path_info = [ ] #NEWLINE# for level_info in path_info : #NEWLINE# #INDENT# if ( len ( level_info ) == 3 ) : #NEWLINE# #INDENT# key_is_id = level_info [ 2 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( level_info ) == 2 ) : #NEWLINE# #INDENT# key_is_id = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise bulkloader_errors . InvalidConfiguration ( ( 'Each list in create_deep_key must specify exactly 2 or 3 parameters, (kind, property, is_id=False). You specified: %s' % repr ( path_info ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# kind_name = level_info [ 0 ] #NEWLINE# property_name = level_info [ 1 ] #NEWLINE# validated_path_info . append ( ( kind_name , property_name , key_is_id ) ) #NEWLINE# #UNINDENT# def create_deep_key_lambda( value , bulkload_state ) : #NEWLINE# #INDENT# path = [ ] #NEWLINE# for ( kind_name , property_name , key_is_id ) in validated_path_info : #NEWLINE# #INDENT# if ( property_name is CURRENT_PROPERTY ) : #NEWLINE# #INDENT# name_or_id = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# name_or_id = bulkload_state . current_dictionary [ property_name ] #NEWLINE# #UNINDENT# if key_is_id : #NEWLINE# #INDENT# name_or_id = int ( name_or_id ) #NEWLINE# #UNINDENT# path += [ kind_name , name_or_id ] #NEWLINE# #UNINDENT# return datastore . Key . from_path ( * path ) #NEWLINE# #UNINDENT# return create_deep_key_lambda