@@ -0,0 +1,2292 @@
+import os%0Aimport sys%0Aimport solvebio%0A%0A%0Adef download_vault_folder(remote_path, local_path, dry_run=False, force=False):%0A    %22%22%22Recursively downloads a folder in a vault to a local directory.%0A    Only downloads files, not datasets.%22%22%22%0A%0A    local_path = os.path.normpath(os.path.expanduser(local_path))%0A    if not os.access(local_path, os.W_OK):%0A        raise Exception(%0A            'Write access to local path (%7B%7D) is required'%0A            .format(local_path))%0A%0A    full_path, path_dict = solvebio.Object.validate_full_path(remote_path)%0A    vault = solvebio.Vault.get_by_full_path(path_dict%5B'vault'%5D)%0A    print('Downloading all files from %7B%7D to %7B%7D'.format(full_path, local_path))%0A%0A    if path_dict%5B'path'%5D == '/':%0A        parent_object_id = None%0A    else:%0A        parent_object = solvebio.Object.get_by_full_path(%0A            remote_path, assert_type='folder')%0A        parent_object_id = parent_object.id%0A%0A    # Scan the folder for all sub-folders and create them locally%0A    print('Creating local directory structure at: %7B%7D'.format(local_path))%0A    if not os.path.exists(local_path):%0A        if not dry_run:%0A            os.makedirs(local_path)%0A%0A    folders = vault.folders(parent_object_id=parent_object_id)%0A    for f in folders:%0A        path = os.path.normpath(local_path + f.path)%0A        if not os.path.exists(path):%0A            print('Creating folder: %7B%7D'.format(path))%0A            if not dry_run:%0A                os.makedirs(path)%0A%0A    files = vault.files(parent_object_id=parent_object_id)%0A    for f in files:%0A        path = os.path.normpath(local_path + f.path)%0A        if os.path.exists(path):%0A            if force:%0A                # Delete the local copy%0A                print('Deleting local file (force download): %7B%7D'.format(path))%0A                if not dry_run:%0A                    os.remove(path)%0A            else:%0A                print('Skipping file (already exists): %7B%7D'.format(path))%0A                continue%0A%0A        print('Downloading file: %7B%7D'.format(path))%0A        if not dry_run:%0A            f.download(path)%0A%0A%0Adef main():%0A    if len(sys.argv) %3C 3:%0A        print('Usage: %7B%7D %3Cvault path%3E %3Clocal path%3E'.format(sys.argv%5B0%5D))%0A        sys.exit(1)%0A%0A    solvebio.login()%0A    download_vault_folder(sys.argv%5B1%5D, sys.argv%5B2%5D, dry_run=True)%0A%0A%0Aif __name__ == '__main__':%0A    main()%0A

add download_vault_folder.py to examples