def filter_files(files, search_str):
    """ Filter a list of files based on a search string
        :param files: list of files to filter (ie ['/a','/a/b', '/a/b/c', '/b']), the order doesn't matter. 'a' and 'a/' are considered different.
        :param search_str, the filtering string (ie 'a')
        
        This function return only first level files/dirs that match the given search string. That is, filtering  ['/a','/a/b','/a/b/c'] with the string 'a' returns only ['/a'],
        This is to avoid polluting the screen with all files inside a directory when a user look for that directory
    """
    matched = set()
    if not search_str:
        for f in files:
            # right strip to the first seperator(ie '/')
            f = f[:_index_or_len(f, os.sep)+1]
            matched.add(f)
    else:
        search_str = search_str.lower()
        for f in files:
            if search_str in f.lower():
                index = f.lower().index(search_str)
                trail = f[index:]
                f = f[:index + _index_or_len(trail, os.sep)+1]
                matched.add(f)
    return matched
dataset/ETHPy150Open pindexis/qfc/qfc/core.py/filter_files/original