How to use the lektor.project.Project.from_path function in Lektor

To help you get started, we’ve selected a few Lektor 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 lektor / lektor / tests / test_themes.py View on Github external
except AttributeError:
        with_themes_var = True

    from lektor.project import Project

    # Create the .lektorproject file
    lektorfile_text = textwrap.dedent(u"""
        [project]
        name = Themes Project
        {}
    """.format("themes = blog_theme, project_theme"
               if with_themes_var else ""))

    theme_project_tmpdir.join("themes.lektorproject").write_text(
        lektorfile_text, "utf8", ensure=True)
    return Project.from_path(str(theme_project_tmpdir))
github lektor / lektor / tests / test_unicode.py View on Github external
def get_unicode_builder(tmpdir):
    from lektor.project import Project
    from lektor.environment import Environment
    from lektor.db import Database
    from lektor.builder import Builder

    proj = Project.from_path(os.path.join(os.path.dirname(__file__),
                                          u'ünicöde-project'))
    env = Environment(proj)
    pad = Database(env).new_pad()

    return pad, Builder(pad, str(tmpdir.mkdir('output')))
github lektor / lektor / tests / test_prev_next_sibling.py View on Github external
def pntest_project(request):
    from lektor.project import Project
    return Project.from_path(os.path.join(os.path.dirname(__file__),
                                          'dependency-test-project'))
github lektor / lektor / tests / test_plugins.py View on Github external
"packages",
        "event-test{}".format(request.param_index),
        "lektor_event_test{}.py".format(request.param_index),
    ).write_text(plugin_text, "utf8", ensure=True)

    # Move into isolated path.
    for entry in os.listdir(str(base)):
        entry_path = os.path.join(str(base), entry)
        if os.path.isdir(entry_path):
            shutil.copytree(entry_path, entry)
        else:
            shutil.copy2(entry_path, entry)

    from lektor.project import Project

    yield (Project.from_path(str(base)), request.param, isolated_cli_runner)
github lektor / lektor-archive / lektor / cli.py View on Github external
def get_project(self, silent=False):
        if self._project is not None:
            return self._project
        if self._project_path is not None:
            rv = Project.from_path(self._project_path)
        else:
            rv = Project.discover()
        if rv is None:
            if silent:
                return None
            raise click.UsageError('Could not find project')
        self._project = rv
        return rv
github lektor / lektor / lektor / cli.py View on Github external
def get_project(self, silent=False):
        if self._project is not None:
            return self._project
        if self._project_path is not None:
            rv = Project.from_path(self._project_path)
        else:
            rv = Project.discover()
        if rv is None:
            if silent:
                return None
            if self._project_path is None:
                raise click.UsageError('Could not automatically discover '
                                       'project.  A Lektor project must '
                                       'exist in the working directory or '
                                       'any of the parent directories.')
            raise click.UsageError('Could not find project "%s"' %
                                   self._project_path)
        self._project = rv
        return rv