parameters: (name: text = None,
           hash: text = None,
           tags: comma_separated_list = None,
           offset: number = 0,
           limit: number = 25)
return_statement: return {
          'total': total,
          'offset': offset,
          'limit': limit,
          'items': file_ext_schema_lite.dump(items, many=True).data,
      }
docstring: Search a file using query filters (tags + hash or name). Support
          pagination.
          :param name: lookup name
          :param hash: lookup hash value
          :param tags: lookup tag list
          :param offset: start index in matching results
          :param limit: max number of results
          :rtype: dict of 'total': int, 'page': int, 'per_page': int,
          'items': list of file(s) found
          :return:
          on success 'items' contains a list of files found
          on error 'msg' gives reason message
docstring_summary: Search a file using query filters (tags + hash or name). Support
          pagination.
          :param name: lookup name
          :param hash: lookup hash value
          :param tags: lookup tag list
          :param offset: start index in matching results
          :param limit: max number of results
          :rtype: dict of 'total': int, 'page': int, 'per_page': int,
          'items': list of file(s) found
          :return:
          on success 'items' contains a list of files found
          on error 'msg' gives reason message
docstring_tokens: Search a file using query filters ( tags + hash or name ) . Support pagination . : param name : lookup name : param hash : lookup hash value : param tags : lookup tag list : param offset : start index in matching results : param limit : max number of results : rtype : dict of total : int page : int per_page : int items : list of file ( s ) found : return : on success items contains a list of files found on error msg gives reason message
function: def list(name: text = None,
           hash: text = None,
           tags: comma_separated_list = None,
           offset: number = 0,
           limit: number = 25):
      """ Search a file using query filters (tags + hash or name). Support
          pagination.
          :param name: lookup name
          :param hash: lookup hash value
          :param tags: lookup tag list
          :param offset: start index in matching results
          :param limit: max number of results
          :rtype: dict of 'total': int, 'page': int, 'per_page': int,
          'items': list of file(s) found
          :return:
          on success 'items' contains a list of files found
          on error 'msg' gives reason message
      """
      session = db.session
      if name is not None:
          name = decode_utf8(name)
  
      log.debug("name %s h_value %s tags %s",
                name, hash, tags)
      if name is not None and hash is not None:
          raise ValueError("Can't find using both name and hash")
  
      if name is not None:
          base_query = FileExt.query_find_by_name(name, tags, session)
      elif hash is not None:
          h_type = guess_hash_type(hash)
  
          if h_type is None:
              raise ValueError("Hash not supported")
  
          base_query = FileExt.query_find_by_hash(
              h_type, hash, tags, session)
      else:
          # FIXME this is just a temporary way to output
          # all files, need a dedicated
          # file route and controller
          base_query = FileExt.query_find_by_name("", tags, session)
  
      # TODO: Find a way to move pagination as a BaseQuery like in
      #       flask_sqlalchemy.
      # https://github.com/mitsuhiko/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L422
      items = base_query.limit(limit).offset(offset).all()
  
      if offset == 0 and len(items) < limit:
          total = len(items)
      else:
          total = base_query.count()
  
      log.debug("Found %s results", total)
      return {
          'total': total,
          'offset': offset,
          'limit': limit,
          'items': file_ext_schema_lite.dump(items, many=True).data,
      }
function_tokens: def list ( name : text = None , hash : text = None , tags : comma_separated_list = None , offset : number = 0 , limit : number = 25 ) : session = db . session if name is not None : name = decode_utf8 ( name ) log . debug ( "name %s h_value %s tags %s" , name , hash , tags ) if name is not None and hash is not None : raise ValueError ( "Can't find using both name and hash" ) if name is not None : base_query = FileExt . query_find_by_name ( name , tags , session ) elif hash is not None : h_type = guess_hash_type ( hash ) if h_type is None : raise ValueError ( "Hash not supported" ) base_query = FileExt . query_find_by_hash ( h_type , hash , tags , session ) else : # FIXME this is just a temporary way to output # all files, need a dedicated # file route and controller base_query = FileExt . query_find_by_name ( "" , tags , session ) # TODO: Find a way to move pagination as a BaseQuery like in #       flask_sqlalchemy. # https://github.com/mitsuhiko/flask-sqlalchemy/blob/master/flask_sqlalchemy/__init__.py#L422 items = base_query . limit ( limit ) . offset ( offset ) . all ( ) if offset == 0 and len ( items ) < limit : total = len ( items ) else : total = base_query . count ( ) log . debug ( "Found %s results" , total ) return { 'total' : total , 'offset' : offset , 'limit' : limit , 'items' : file_ext_schema_lite . dump ( items , many = True ) . data , }