How to use the pyscaffold.api.helpers 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_register_default_position():
    # Given an action list with define_structure,
    actions = [api.init_git, define_structure, init_git]
    # When a new action is registered without position reference,
    actions = helpers.register(actions, custom_action)
    # Then this action should be placed after define_structure
    assert actions == [api.init_git, define_structure, custom_action, init_git]
github pyscaffold / pyscaffold / tests / test_api.py View on Github external
def add_files(struct, opts):
        struct = helpers.ensure(struct, "proj/tests/extra.file", "content")
        struct = helpers.merge(struct, {"proj": {"tests": {"another.file": "content"}}})

        return struct, opts
github pyscaffold / pyscaffoldext-markdown / src / pyscaffoldext / markdown / extension.py View on Github external
:obj:`dict`.
            opts (dict): given options, see :obj:`create_project` for
                an extensive list.

        Returns:
            struct, opts: updated project representation and options
        """
        if opts["update"] and not opts["force"]:
            return struct, opts
        for file, template in self.CONV_FILES.items():
            # remove rst file
            file_path = [opts["project"], "{}.rst".format(file)]
            struct = helpers.reject(struct, file_path)
            # add md file
            file_path = [opts["project"], "{}.md".format(file)]
            struct = helpers.ensure(struct, file_path, template(opts))

        file_path = [opts["project"], "setup.cfg"]
        struct = helpers.modify(struct, file_path, self.add_long_desc)

        # use when docutils issue is fixed, see #1
        # for file in ('authors.rst', 'changelog.rst'):
        #    file_path = [opts['project'], 'docs', file]
        #    struct = helpers.modify(struct, file_path, self.rst2md)
        file_path = [opts["project"], "docs", "conf.py"]
        struct = helpers.modify(struct, file_path, self.add_sphinx_md)

        return struct, opts
github pyscaffold / pyscaffoldext-dsproject / src / pyscaffoldext / dsproject / extension.py View on Github external
def add_dsproject(struct, opts):
    """Adds basic module for custom extension

    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
    """
    gitignore_all = templates.gitignore_all(opts)

    path = [opts["project"], "data", ".gitignore"]
    struct = helpers.ensure(
        struct, path, templates.gitignore_data(opts), helpers.NO_OVERWRITE
    )
    for folder in ("external", "interim", "preprocessed", "raw"):
        path = [opts["project"], "data", folder, ".gitignore"]
        struct = helpers.ensure(struct, path, gitignore_all, helpers.NO_OVERWRITE)

    path = [opts["project"], "notebooks", "template.ipynb"]
    template_ipynb = templates.template_ipynb(opts)
    struct = helpers.ensure(struct, path, template_ipynb, helpers.NO_OVERWRITE)

    path = [opts["project"], "scripts", "train_model.py"]
    train_model_py = templates.train_model_py(opts)
    struct = helpers.ensure(struct, path, train_model_py, helpers.NO_OVERWRITE)

    path = [opts["project"], "models", ".gitignore"]
    struct = helpers.ensure(struct, path, gitignore_all, helpers.NO_OVERWRITE)
github pyscaffold / pyscaffoldext-markdown / src / pyscaffoldext / markdown / extension.py View on Github external
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
        """
        if opts["update"] and not opts["force"]:
            return struct, opts
        for file, template in self.CONV_FILES.items():
            # remove rst file
            file_path = [opts["project"], "{}.rst".format(file)]
            struct = helpers.reject(struct, file_path)
            # add md file
            file_path = [opts["project"], "{}.md".format(file)]
            struct = helpers.ensure(struct, file_path, template(opts))

        file_path = [opts["project"], "setup.cfg"]
        struct = helpers.modify(struct, file_path, self.add_long_desc)

        # use when docutils issue is fixed, see #1
        # for file in ('authors.rst', 'changelog.rst'):
        #    file_path = [opts['project'], 'docs', file]
        #    struct = helpers.modify(struct, file_path, self.rst2md)
        file_path = [opts["project"], "docs", "conf.py"]
        struct = helpers.modify(struct, file_path, self.add_sphinx_md)

        return struct, opts
github pyscaffold / pyscaffoldext-dsproject / src / pyscaffoldext / dsproject / extension.py View on Github external
path = [opts["project"], "data", folder, ".gitignore"]
        struct = helpers.ensure(struct, path, gitignore_all, helpers.NO_OVERWRITE)

    path = [opts["project"], "notebooks", "template.ipynb"]
    template_ipynb = templates.template_ipynb(opts)
    struct = helpers.ensure(struct, path, template_ipynb, helpers.NO_OVERWRITE)

    path = [opts["project"], "scripts", "train_model.py"]
    train_model_py = templates.train_model_py(opts)
    struct = helpers.ensure(struct, path, train_model_py, helpers.NO_OVERWRITE)

    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