コード例 #1
0
ファイル: test_dataset.py プロジェクト: ltalirz/renku-python
def test_unlink_default(directory_tree, client):
    """Test unlink default behaviour."""
    with chdir(client.path):
        create_dataset("dataset")
        add_file([directory_tree.join("dir2").strpath], "dataset")

    with pytest.raises(ParameterError):
        file_unlink("dataset", (), ())
コード例 #2
0
ファイル: dataset.py プロジェクト: mohammad-sdsc/renku-python
def unlink(short_name, include, exclude, yes):
    """Remove matching files from a dataset."""
    file_unlink(
        short_name=short_name,
        include=include,
        exclude=exclude,
        yes=yes,
        interactive=True
    )

    click.secho('OK', fg='green')
コード例 #3
0
ファイル: datasets.py プロジェクト: ltalirz/renku-python
def unlink_file_view(user_data, cache):
    """Unlink a file from a dataset."""
    ctx = DatasetUnlinkRequest().load(request.json)

    include = ctx.get("include_filter")
    exclude = ctx.get("exclude_filter")

    user = cache.ensure_user(user_data)
    project = cache.get_project(user, ctx["project_id"])

    if ctx.get("commit_message") is None:
        if include and exclude:
            filters = "-I {0} -X {1}".format(include, exclude)
        elif not include and exclude:
            filters = "-X {0}".format(exclude)
        else:
            filters = "-I {0}".format(include)

        ctx["commit_message"] = "service: unlink dataset {0} {1}".format(
            ctx["name"], filters)

    with chdir(project.abs_path):
        records = file_unlink(
            name=ctx["name"],
            include=ctx.get("include_filters"),
            exclude=ctx.get("exclude_filters"),
            yes=True,
            interactive=False,
            commit_message=ctx["commit_message"],
        )

        unlinked = [record.path for record in records]

    return result_response(DatasetUnlinkResponseRPC(), {"unlinked": unlinked})
コード例 #4
0
def unlink_file_view(user_data, cache):
    """Unlink a file from a dataset."""
    ctx = DatasetUnlinkRequest().load(request.json)

    include = ctx.get('include_filter')
    exclude = ctx.get('exclude_filter')

    user = cache.ensure_user(user_data)
    project = cache.get_project(user, ctx['project_id'])

    if ctx.get('commit_message') is None:
        if include and exclude:
            filters = '-I {0} -X {0}'.format(include, exclude)
        elif not include and exclude:
            filters = '-X {0}'.format(exclude)
        else:
            filters = '-I {0}'.format(include)

        ctx['commit_message'] = ('service: unlink dataset {0} {1}'.format(
            ctx['short_name'], filters))

    with chdir(project.abs_path):
        records = file_unlink(short_name=ctx['short_name'],
                              include=ctx.get('include_filters'),
                              exclude=ctx.get('exclude_filters'),
                              yes=True,
                              interactive=False,
                              commit_message=ctx['commit_message'])

        unlinked = [record.path for record in records]

    return result_response(DatasetUnlinkResponseRPC(), {'unlinked': unlinked})
コード例 #5
0
def unlink(short_name, include, exclude, yes):
    """Remove matching files from a dataset."""
    with file_unlink(short_name, include, exclude) as records:
        if not yes and records:
            prompt_text = (
                'You are about to remove '
                'following from "{0}" dataset.\n'.format(short_name) +
                '\n'.join([str(record.full_path) for record in records]) +
                '\nDo you wish to continue?'
            )
            click.confirm(WARNING + prompt_text, abort=True)

    click.secho('OK', fg='green')
コード例 #6
0
ファイル: dataset.py プロジェクト: ltalirz/renku-python
def unlink(name, include, exclude, yes):
    """Remove matching files from a dataset."""
    file_unlink(name=name, include=include, exclude=exclude, yes=yes, interactive=True)

    click.secho("OK", fg="green")