def get_content(self): default_variables = {"env": self.env, "repr": repr, "str": str, "bool": bool} variables = checked_unite(default_variables, self.imports_dict) self.context.update(variables) rendered = self.template.render(self.context) return rendered + "\n" if not rendered.endswith("\n") else rendered
def get_content(self): default_variables = { 'env':self.env, 'repr':repr, 'str':str, 'bool':bool } variables = checked_unite(default_variables, self.imports_dict) self.context.update(variables) rendered = self.template.render(self.context) return rendered + "\n" if not rendered.endswith('\n') else rendered
def format(self, format_string, *args, **kwargs): env = Environment.get_instance() variables = kwargs params = env.config.params result = checked_unite(variables, params) return self.vformat(format_string, args, result)
def format(format_string, *args, **kwargs): env = Environment.get_instance() variables = sys._getframe(1).f_locals result = checked_unite(kwargs, variables) result.pop("self", None) # self kwarg would result in an error return env.formatter.format(format_string, args, **result)
def get_content(self): default_variables = { 'env':self.env, 'repr':repr, 'str':str, 'bool':bool, 'unicode':unicode } variables = checked_unite(default_variables, self.imports_dict) self.context.update(variables) rendered = self.template.render(self.context) return rendered
def __init__(self, name, extra_imports=[], **kwargs): """ @param kwargs: Additional variables passed to template """ super(Template, self).__init__(name) params = self.env.config.params variables = checked_unite(params, kwargs) self.imports_dict = dict((module.__name__, module) for module in extra_imports) self.context = variables.copy() if variables else {} if not hasattr(self, 'template_env'): self.template_env = JinjaEnvironment(loader=TemplateLoader(self.env), autoescape=False, undefined=StrictUndefined, trim_blocks=True) self.template = self.template_env.get_template(self.name)
def format(self, format_string, *args, **kwargs): env = Environment.get_instance() variables = kwargs params = env.config.params all_params = checked_unite(variables, params) self.convert_field = self.convert_field_protected result_protected = self.vformat(format_string, args, all_params) self.convert_field = self.convert_field_unprotected result_unprotected = self.vformat(format_string, args, all_params) if result_protected != result_unprotected: Logger.sensitive_strings[result_unprotected] = result_protected return result_unprotected
def format(format_string, *args, **kwargs): variables = sys._getframe(1).f_locals result = checked_unite(kwargs, variables) result.pop("self", None) # self kwarg would result in an error return ConfigurationFormatter().format(format_string, args, **result)