#NEWLINE# def trim_start( self , names_with_path ) : #NEWLINE# #INDENT# '\n        Trims joins from the start of the join path. The candidates for trim\n        are the PathInfos in names_with_path structure that are m2m joins.\n\n        Also sets the select column so the start matches the join.\n\n        This method is meant to be used for generating the subquery joins &\n        cols in split_exclude().\n\n        Returns a lookup usable for doing outerq.filter(lookup=self). Returns\n        also if the joins in the prefix contain a LEFT OUTER join.\n        _' #NEWLINE# all_paths = [ ] #NEWLINE# for ( _ , paths ) in names_with_path : #NEWLINE# #INDENT# all_paths . extend ( paths ) #NEWLINE# #UNINDENT# contains_louter = False #NEWLINE# lookup_tables = [ t for t in self . tables if ( ( t in self . _lookup_joins ) or ( t == self . tables [ 0 ] ) ) ] #NEWLINE# for ( trimmed_paths , path ) in enumerate ( all_paths ) : #NEWLINE# #INDENT# if path . m2m : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# if ( self . alias_map [ lookup_tables [ ( trimmed_paths + 1 ) ] ] . join_type == self . LOUTER ) : #NEWLINE# #INDENT# contains_louter = True #NEWLINE# #UNINDENT# self . unref_alias ( lookup_tables [ trimmed_paths ] ) #NEWLINE# #UNINDENT# join_field = path . join_field . field #NEWLINE# paths_in_prefix = trimmed_paths #NEWLINE# trimmed_prefix = [ ] #NEWLINE# for ( name , path ) in names_with_path : #NEWLINE# #INDENT# if ( ( paths_in_prefix - len ( path ) ) < 0 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# trimmed_prefix . append ( name ) #NEWLINE# paths_in_prefix -= len ( path ) #NEWLINE# #UNINDENT# trimmed_prefix . append ( join_field . foreign_related_fields [ 0 ] . name ) #NEWLINE# trimmed_prefix = LOOKUP_SEP . join ( trimmed_prefix ) #NEWLINE# if ( self . alias_map [ lookup_tables [ ( trimmed_paths + 1 ) ] ] . join_type != self . LOUTER ) : #NEWLINE# #INDENT# select_fields = [ r [ 0 ] for r in join_field . related_fields ] #NEWLINE# select_alias = lookup_tables [ ( trimmed_paths + 1 ) ] #NEWLINE# self . unref_alias ( lookup_tables [ trimmed_paths ] ) #NEWLINE# extra_restriction = join_field . get_extra_restriction ( self . where_class , None , lookup_tables [ ( trimmed_paths + 1 ) ] ) #NEWLINE# if extra_restriction : #NEWLINE# #INDENT# self . where . add ( extra_restriction , AND ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# select_fields = [ r [ 1 ] for r in join_field . related_fields ] #NEWLINE# select_alias = lookup_tables [ trimmed_paths ] #NEWLINE# #UNINDENT# self . select = [ SelectInfo ( ( select_alias , f . column ) , f ) for f in select_fields ] #NEWLINE# return ( trimmed_prefix , contains_louter )