def handle_command_line(options): """ act upon command options """ options = merge(options, constants.DEFAULT_OPTIONS) if options[constants.LABEL_TEMPLATE] is None: print(ERROR_NO_TEMPLATE) sys.exit(-1) engine_class = EngineFactory.get_engine( options[constants.LABEL_TEMPLATE_TYPE]) engine = engine_class(options[constants.LABEL_TMPL_DIRS], options[constants.LABEL_CONFIG_DIR]) engine.render_to_file( options[constants.LABEL_TEMPLATE], options[constants.LABEL_CONFIG], options[constants.LABEL_OUTPUT] )
def handle_moban_file_v1(moban_file_configurations, command_line_options): merged_options = None if constants.LABEL_CONFIG in moban_file_configurations: merged_options = merge( command_line_options, moban_file_configurations[constants.LABEL_CONFIG]) merged_options = merge( command_line_options, constants.DEFAULT_OPTIONS) list_of_templating_parameters = parse_targets( merged_options, moban_file_configurations[constants.LABEL_TARGETS]) engine_class = EngineFactory.get_engine( merged_options[constants.LABEL_TEMPLATE_TYPE]) engine = engine_class( merged_options[constants.LABEL_TMPL_DIRS], merged_options[constants.LABEL_CONFIG_DIR]) engine.render_to_files(list_of_templating_parameters)
def test_default_template_type(): engine_class = EngineFactory.get_engine("jinja2") assert engine_class == Engine
def test_unknown_template_type(): EngineFactory.get_engine("unknown_template_type")
def test_default_mako_type(): # fake mako engine_class = EngineFactory.get_engine("mako") assert engine_class == Engine