How to use the autohooks.setting.Mode function in autohooks

To help you get started, we’ve selected a few autohooks 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 greenbone / autohooks / tests / test_template.py View on Github external
def test_should_use_default_template(self):
        template = PreCommitTemplate()
        self.assertEqual(
            template.render(mode=Mode.PYTHONPATH), DEFAULT_TEMPLATE
        )
github greenbone / autohooks / tests / test_template.py View on Github external
def test_should_render_mode_pipenv(self):
        path = FakeTemplatePath("$SHEBANG")
        template = PreCommitTemplate(path)
        self.assertEqual(
            template.render(mode=Mode.PIPENV),
            "/usr/bin/env -S pipenv run python3",
        )
github greenbone / autohooks / autohooks / template.py View on Github external
def render(self, *, mode: Mode) -> str:
        mode = mode.get_effective_mode()

        if mode == Mode.PIPENV:
            params = dict(SHEBANG=PIPENV_SHEBANG)
        elif mode == Mode.POETRY:
            params = dict(SHEBANG=POETRY_SHEBANG)
        else:
            params = dict(SHEBANG=PYTHON3_SHEBANG)

        return self._template.safe_substitute(params)
github greenbone / autohooks / autohooks / template.py View on Github external
def render(self, *, mode: Mode) -> str:
        mode = mode.get_effective_mode()

        if mode == Mode.PIPENV:
            params = dict(SHEBANG=PIPENV_SHEBANG)
        elif mode == Mode.POETRY:
            params = dict(SHEBANG=POETRY_SHEBANG)
        else:
            params = dict(SHEBANG=PYTHON3_SHEBANG)

        return self._template.safe_substitute(params)