nodes: 0, module; 1, function_definition; 2, function_name:list; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, dictionary_splat_pattern; 11, expression_statement; 12, try_statement; 13, identifier:offset; 14, integer:0; 15, identifier:limit; 16, integer:0; 17, identifier:fields; 18, None; 19, identifier:sort; 20, None; 21, identifier:kwargs; 22, comment:"""Return filtered list of documents in a collection.
  
          For text-based search, we support searching on a name/string field by
          regex and text index. So strings passed in to a r=text search are
          used to filter collections by text index and regex on a named field.
  
          :param offset: for pagination, which record to start attribute
          :param limit: for pagination, how many records to return
          :param fields: list of field names to return (otherwise returns all)
          :param sort: list of fields to sort by (prefix with '-' for descending)
          :param kwargs: key/values to find (only supports equality for now)
  
          :returns: a tuple of the list of documents and the total count
          """; 23, block; 24, except_clause; 25, expression_statement; 26, return_statement; 27, as_pattern; 28, comment:# This is workaround for mongodb v2.4 and 'q' filter params; 29, block; 30, assignment; 31, expression_list; 32, attribute; 33, as_pattern_target; 34, try_statement; 35, expression_statement; 36, expression_statement; 37, expression_statement; 38, expression_statement; 39, return_statement; 40, identifier:cursor; 41, call; 42, call; 43, call; 44, attribute; 45, identifier:OperationFailure; 46, identifier:exc; 47, block; 48, except_clause; 49, call; 50, assignment; 51, call; 52, assignment; 53, expression_list; 54, attribute; 55, argument_list; 56, identifier:list; 57, argument_list; 58, attribute; 59, argument_list; 60, identifier:pymongo; 61, identifier:errors; 62, expression_statement; 63, tuple; 64, block; 65, attribute; 66, argument_list; 67, identifier:kwargs; 68, call; 69, attribute; 70, argument_list; 71, identifier:cursor; 72, call; 73, call; 74, call; 75, identifier:self; 76, identifier:_cursor; 77, keyword_argument; 78, keyword_argument; 79, keyword_argument; 80, keyword_argument; 81, dictionary_splat; 82, identifier:cursor; 83, identifier:cursor; 84, identifier:count; 85, subscript; 86, identifier:KeyError; 87, identifier:IndexError; 88, raise_statement; 89, identifier:LOG; 90, identifier:warn; 91, string:"Falling back to hard-coded mongo v2.4 search behavior"; 92, attribute; 93, argument_list; 94, identifier:LOG; 95, identifier:debug; 96, string:"Modified kwargs: %s"; 97, identifier:kwargs; 98, attribute; 99, argument_list; 100, identifier:list; 101, argument_list; 102, attribute; 103, argument_list; 104, identifier:offset; 105, identifier:offset; 106, identifier:limit; 107, identifier:limit; 108, identifier:fields; 109, identifier:fields; 110, identifier:sort; 111, identifier:sort; 112, identifier:kwargs; 113, subscript; 114, string; 115, identifier:exc; 116, identifier:self; 117, identifier:search_alternative; 118, identifier:limit; 119, dictionary_splat; 120, identifier:self; 121, identifier:_cursor; 122, keyword_argument; 123, keyword_argument; 124, keyword_argument; 125, keyword_argument; 126, dictionary_splat; 127, identifier:cursor; 128, identifier:cursor; 129, identifier:count; 130, subscript; 131, string; 132, string_content:$search; 133, identifier:kwargs; 134, identifier:offset; 135, identifier:offset; 136, identifier:limit; 137, identifier:limit; 138, identifier:fields; 139, identifier:fields; 140, identifier:sort; 141, identifier:sort; 142, identifier:kwargs; 143, subscript; 144, integer:0; 145, string_content:$text; 146, identifier:kwargs; 147, string; 148, string_content:$or
code: def list(self, offset=0, limit=0, fields=None, sort=None, **kwargs):
          """Return filtered list of documents in a collection.
  
          For text-based search, we support searching on a name/string field by
          regex and text index. So strings passed in to a r=text search are
          used to filter collections by text index and regex on a named field.
  
          :param offset: for pagination, which record to start attribute
          :param limit: for pagination, how many records to return
          :param fields: list of field names to return (otherwise returns all)
          :param sort: list of fields to sort by (prefix with '-' for descending)
          :param kwargs: key/values to find (only supports equality for now)
  
          :returns: a tuple of the list of documents and the total count
          """
          try:
              cursor = self._cursor(offset=offset, limit=limit, fields=fields,
                                    sort=sort, **kwargs)
              return list(cursor), cursor.count()
          except pymongo.errors.OperationFailure as exc:
              # This is workaround for mongodb v2.4 and 'q' filter params
              try:
                  kwargs['$or'][0]['$text']['$search']
              except (KeyError, IndexError):
                  raise exc
              LOG.warn("Falling back to hard-coded mongo v2.4 search behavior")
              kwargs = self.search_alternative(limit, **kwargs)
              LOG.debug("Modified kwargs: %s", kwargs)
              cursor = self._cursor(offset=offset, limit=limit, fields=fields,
                                    sort=sort, **kwargs)
              return list(cursor), cursor.count()