confighelper: add load_template method
This is an alternative to gettemplate that always returns a template. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a4f960d40c
commit
a269de5dc0
|
@ -350,6 +350,18 @@ class ConfigHelper:
|
|||
return self._get_option(gettemplate_wrapper, option, default,
|
||||
deprecate=deprecate)
|
||||
|
||||
def load_template(self,
|
||||
option: str,
|
||||
default: Union[SentinelClass, str] = SENTINEL,
|
||||
deprecate: bool = False
|
||||
) -> JinjaTemplate:
|
||||
val = self.gettemplate(option, default, deprecate)
|
||||
if isinstance(val, str):
|
||||
template: TemplateFactory
|
||||
template = self.server.lookup_component('template')
|
||||
return template.create_template(val)
|
||||
return val
|
||||
|
||||
def read_supplemental_config(self, file_name: str) -> ConfigHelper:
|
||||
cfg_file_path = os.path.normpath(os.path.expanduser(file_name))
|
||||
if not os.path.isfile(cfg_file_path):
|
||||
|
|
Loading…
Reference in New Issue