コード例 #1
0
ファイル: argprocessor.py プロジェクト: cjerdonek/molt
def _render(options, args, chooser):
    template_dir = _get_input_dir(options, args, 'template rendering')

    config_path = options.config_path
    output_dir = _make_output_directory(options, defaults.OUTPUT_DIR)

    molter = Molter(chooser=chooser)
    molter.molt(template_dir=template_dir,
                output_dir=output_dir,
                config_path=config_path)

    if options.with_visualize:
        visualize(output_dir)

    return output_dir
コード例 #2
0
ファイル: templatetest.py プロジェクト: philipn/molt
    def assert_template(self, template_name, long_name, template_dir, expected_dir, should_stage=False):
        """
        Arguments:

          template_name: the short name for the template.

          template_dir: the directory containing the lambdas directory,
            partials directory, etc.

          should_stage: whether to stage the template directory.  This option
            is useful, for example, if the executable bit is not set on the
            lambda scripts in the original template lambdas directory.

        """
        molter = Molter()

        with self.sandboxDir() as temp_dir:
            actual_dir = os.path.join(temp_dir, "actual")
            os.mkdir(actual_dir)

            if should_stage:
                staged_template_dir = os.path.join(temp_dir, "template")
                stage_template_dir(template_dir, staged_template_dir)
                template_dir = staged_template_dir

            context = molter.get_context(template_dir)
            config = molter.read_config(template_dir)
            description = config["description"]

            molter.molt(template_dir=template_dir, output_dir=actual_dir)
            format_msg = _make_format_msg(
                actual_dir, expected_dir, context=context, test_name=template_name, test_description=description
            )
            self.assertDirectoriesEqual(
                actual_dir, expected_dir, fuzzy=True, format_msg=format_msg, should_ignore=should_ignore_file
            )