How to use the pyscaffold.api.helpers.reject function in PyScaffold

To help you get started, we’ve selected a few PyScaffold examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyscaffold / pyscaffold / tests / api / test_helpers.py View on Github external
def test_reject_without_ancestor():
    # Given a defined structure,
    structure = {"a": {"b": {"c": "0"}}}
    # when someone tries to remove a file using the reject method
    # but one of its ancestor does not exist in the structure,
    structure = helpers.reject(structure, "a/b/x/c")
    # then the structure should be the same
    assert structure["a"]["b"]["c"] == "0"
    assert len(structure["a"]["b"]["c"]) == 1
    assert len(structure["a"]["b"]) == 1
    assert len(structure["a"]) == 1
github pyscaffold / pyscaffold / tests / api / test_helpers.py View on Github external
def test_reject_without_file():
    # Given a defined structure,
    structure = {"a": {"b": {"c": "0"}}}
    # when someone tries to remove a file using the reject method
    # but one of its ancestor does not exist in the structure,
    structure = helpers.reject(structure, "a/b/x")
    # then the structure should be the same
    assert structure["a"]["b"]["c"] == "0"
    assert len(structure["a"]["b"]["c"]) == 1
    assert len(structure["a"]["b"]) == 1
    assert len(structure["a"]) == 1
github pyscaffold / pyscaffold / tests / api / test_helpers.py View on Github external
def test_reject():
    # When the original structure contain a leaf
    structure = {"a": {"b": {"c": "0"}}}
    # that is removed using the reject method,
    structure = helpers.reject(structure, Path("a", "b", "c"))
    # then the structure should not contain the file
    assert "c" not in structure["a"]["b"]
github pyscaffold / pyscaffoldext-dsproject / src / pyscaffoldext / dsproject / extension.py View on Github external
path = [opts["project"], "models", ".gitignore"]
    struct = helpers.ensure(struct, path, gitignore_all, helpers.NO_OVERWRITE)

    path = [opts["project"], "references", ".gitignore"]
    struct = helpers.ensure(struct, path, "", helpers.NO_OVERWRITE)

    path = [opts["project"], "reports", "figures", ".gitignore"]
    struct = helpers.ensure(struct, path, "", helpers.NO_OVERWRITE)

    path = [opts["project"], "environment.yaml"]
    environment_yaml = templates.environment_yaml(opts)
    struct = helpers.ensure(struct, path, environment_yaml, helpers.NO_OVERWRITE)

    path = [opts["project"], "requirements.txt"]
    struct = helpers.reject(struct, path)

    path = [opts["project"], "configs", ".gitignore"]
    struct = helpers.ensure(struct, path, "", helpers.NO_OVERWRITE)
    return struct, opts
github pyscaffold / pyscaffoldext-dsproject / src / pyscaffoldext / dsproject / extension.py View on Github external
"""Replace the readme.md of the markdown extension by our own

    Args:
        struct (dict): project representation as (possibly) nested
            :obj:`dict`.
        opts (dict): given options, see :obj:`create_project` for
            an extensive list.

    Returns:
        struct, opts: updated project representation and options
    """
    # let the markdown extension do its job first
    struct, opts = MarkDown("markdown").markdown(struct, opts)

    file_path = [opts["project"], "README.md"]
    struct = helpers.reject(struct, file_path)
    readme = templates.readme_md(opts)
    struct = helpers.ensure(struct, file_path, readme, helpers.NO_OVERWRITE)
    return struct, opts