예제 #1
0
    def from_file(cls, filename):
        """Reads a project from a project file."""
        inifile = IniFile(filename)
        if inifile.is_new:
            return None

        name = (inifile.get("project.name")
                or os.path.basename(filename).rsplit(".")[0].title())
        path = os.path.join(
            os.path.dirname(filename),
            untrusted_to_os_path(inifile.get("project.path") or "."),
        )

        themes = inifile.get("project.themes")
        if themes is not None:
            themes = [x.strip() for x in themes.split(",")]
        else:
            themes = []

        return cls(
            name=name,
            project_file=filename,
            tree=path,
            themes=themes,
        )
예제 #2
0
파일: project.py 프로젝트: rubenbe/lektor
    def from_file(cls, filename):
        """Reads a project from a project file."""
        inifile = IniFile(filename)
        if inifile.is_new:
            return None

        name = inifile.get('project.name') or os.path.basename(
            filename).rsplit('.')[0].title()
        path = os.path.join(os.path.dirname(filename),
                            untrusted_to_os_path(
                                inifile.get('project.path') or '.'))
        return cls(
            name=name,
            project_file=filename,
            tree=path,
        )
예제 #3
0
파일: project.py 프로젝트: sunliwen/lektor
    def from_file(cls, filename):
        """Reads a project from a project file."""
        inifile = IniFile(filename)
        if inifile.is_new:
            return None

        name = inifile.get('project.name') or os.path.basename(
            filename).rsplit('.')[0].title()
        path = os.path.join(os.path.dirname(filename),
                            untrusted_to_os_path(
                                inifile.get('project.path') or '.'))

        themes = inifile.get('project.themes')
        if themes is not None:
            themes = [x.strip() for x in themes.split(',')]
        else:
            themes = []

        return cls(
            name=name,
            project_file=filename,
            tree=path,
            themes=themes,
        )