def list_projects(folders, folder = None, user = None):
    '''List all folders or all subfolders of a folder.

    If folder is provided, this method will output a list of subfolders
    contained by it.  Otherwise, a list of all top-level folders is produced.

    :param folders: reference to folder.Folders instance
    :param folder: folder name or None
    :param user: optional user name

    '''
    fid = None if folder is None else Folders.name_to_id(folder)

    # List all folders if none provided.
    if fid is None:
        for f in folders.folders(user):
            print(Folders.id_to_name(f))

        return

    # List subfolders of a specific folder
    try:
        for sid in folders.subfolders(fid, user):
            print(Folders.id_to_name(sid))
    except __HOLE__:
        print("E: folder not found: %s" %folder, file=sys.stderr)
dataset/ETHPy150Open dossier/dossier.models/dossier/models/query.py/list_projects