当前位置: 首页>>代码示例>>Python>>正文


Python TemplatePagesGenerator.generate_output方法代码示例

本文整理汇总了Python中pelican.generators.TemplatePagesGenerator.generate_output方法的典型用法代码示例。如果您正苦于以下问题:Python TemplatePagesGenerator.generate_output方法的具体用法?Python TemplatePagesGenerator.generate_output怎么用?Python TemplatePagesGenerator.generate_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pelican.generators.TemplatePagesGenerator的用法示例。


在下文中一共展示了TemplatePagesGenerator.generate_output方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_turkish_locale

# 需要导入模块: from pelican.generators import TemplatePagesGenerator [as 别名]
# 或者: from pelican.generators.TemplatePagesGenerator import generate_output [as 别名]
    def test_turkish_locale(self):
        if platform == 'win32':
            locale_string = 'Turkish'
        else:
            locale_string = 'tr_TR.UTF-8'
        settings = read_settings(
            override={
                'LOCALE': locale_string,
                'TEMPLATE_PAGES': {
                    'template/source.html': 'generated/file.html'
                }
            })

        generator = TemplatePagesGenerator(
            {'date': self.date}, settings,
            self.temp_content, '', self.temp_output)
        generator.env.filters.update({'strftime': utils.DateFormatter()})

        writer = Writer(self.temp_output, settings=settings)
        generator.generate_output(writer)

        output_path = os.path.join(
            self.temp_output, 'generated', 'file.html')

        # output file has been generated
        self.assertTrue(os.path.exists(output_path))

        # output content is correct
        with utils.pelican_open(output_path) as output_file:
            self.assertEqual(output_file,
                             utils.strftime(self.date, 'date = %A, %d %B %Y'))
开发者ID:AlexJF,项目名称:pelican,代码行数:33,代码来源:test_utils.py

示例2: test_generate_output

# 需要导入模块: from pelican.generators import TemplatePagesGenerator [as 别名]
# 或者: from pelican.generators.TemplatePagesGenerator import generate_output [as 别名]
    def test_generate_output(self):

        settings = get_settings()
        settings['STATIC_PATHS'] = ['static']
        settings['TEMPLATE_PAGES'] = {
                'template/source.html': 'generated/file.html'
                }

        generator = TemplatePagesGenerator({'foo': 'bar'}, settings,
                self.temp_content, '', self.temp_output, None)

        # create a dummy template file
        template_dir = os.path.join(self.temp_content, 'template')
        template_path = os.path.join(template_dir, 'source.html')
        os.makedirs(template_dir)
        with open(template_path, 'w') as template_file:
            template_file.write(self.TEMPLATE_CONTENT)

        writer = Writer(self.temp_output, settings=settings)
        generator.generate_output(writer)

        output_path = os.path.join(
                self.temp_output, 'generated', 'file.html')

        # output file has been generated
        self.assertTrue(os.path.exists(output_path))

        # output content is correct
        with open(output_path, 'r') as output_file:
            self.assertEqual(output_file.read(), 'foo: bar')
开发者ID:AndreLesa,项目名称:pelican,代码行数:32,代码来源:test_generators.py

示例3: test_generate_output

# 需要导入模块: from pelican.generators import TemplatePagesGenerator [as 别名]
# 或者: from pelican.generators.TemplatePagesGenerator import generate_output [as 别名]
    def test_generate_output(self):

        settings = get_settings()
        settings["STATIC_PATHS"] = ["static"]
        settings["TEMPLATE_PAGES"] = {"template/source.html": "generated/file.html"}

        generator = TemplatePagesGenerator(
            context={"foo": "bar"}, settings=settings, path=self.temp_content, theme="", output_path=self.temp_output
        )

        # create a dummy template file
        template_dir = os.path.join(self.temp_content, "template")
        template_path = os.path.join(template_dir, "source.html")
        os.makedirs(template_dir)
        with open(template_path, "w") as template_file:
            template_file.write(self.TEMPLATE_CONTENT)

        writer = Writer(self.temp_output, settings=settings)
        generator.generate_output(writer)

        output_path = os.path.join(self.temp_output, "generated", "file.html")

        # output file has been generated
        self.assertTrue(os.path.exists(output_path))

        # output content is correct
        with open(output_path, "r") as output_file:
            self.assertEqual(output_file.read(), "foo: bar")
开发者ID:entelesis,项目名称:pelican,代码行数:30,代码来源:test_generators.py

示例4: test_turkish_locale

# 需要导入模块: from pelican.generators import TemplatePagesGenerator [as 别名]
# 或者: from pelican.generators.TemplatePagesGenerator import generate_output [as 别名]
    def test_turkish_locale(self):
        settings = read_settings(
            override={
                "LOCALE": locale.normalize("tr_TR.UTF-8"),
                "TEMPLATE_PAGES": {"template/source.html": "generated/file.html"},
            }
        )

        generator = TemplatePagesGenerator({"date": self.date}, settings, self.temp_content, "", self.temp_output)
        generator.env.filters.update({"strftime": utils.DateFormatter()})

        writer = Writer(self.temp_output, settings=settings)
        generator.generate_output(writer)

        output_path = os.path.join(self.temp_output, "generated", "file.html")

        # output file has been generated
        self.assertTrue(os.path.exists(output_path))

        # output content is correct
        with utils.pelican_open(output_path) as output_file:
            self.assertEqual(output_file, utils.strftime(self.date, "date = %A, %d %B %Y"))
开发者ID:dmpeters,项目名称:pelican,代码行数:24,代码来源:test_utils.py

示例5: generate_output

# 需要导入模块: from pelican.generators import TemplatePagesGenerator [as 别名]
# 或者: from pelican.generators.TemplatePagesGenerator import generate_output [as 别名]
    def generate_output(self, article, templates, file_num):
        settings = self.settings
        settings['TEMPLATE_PAGES'] = templates

        generator = TemplatePagesGenerator(
            context={'article': article, 'current_page': file_num},
            settings=settings,
            path=settings['PATH'],
            theme=settings['THEME'],
            output_path=self.output_path
        )

        writer = Writer(self.output_path, settings=settings)
        generator.generate_output(writer)

        output_path = os.path.join(self.output_path, 'generated', 'file.html')

        # output content is correct
        with open(output_path, 'r') as output_file:
            rendered_html = output_file.read()

        return rendered_html
开发者ID:Shaked,项目名称:articles_list,代码行数:24,代码来源:html_parser.py


注:本文中的pelican.generators.TemplatePagesGenerator.generate_output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。