17 lines
474 B
Python
17 lines
474 B
Python
|
""" Reads an XML template from a file """
|
||
|
|
||
|
import os
|
||
|
|
||
|
|
||
|
class XMLTemplate:
|
||
|
""" Reads and instanciates a template from a file """
|
||
|
|
||
|
def __init__(self, path):
|
||
|
self.path = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
|
||
|
with open(self.path, "r") as handle:
|
||
|
self.template_str = handle.read()
|
||
|
|
||
|
def inst(self, *args, **kwargs):
|
||
|
""" instanciates the template """
|
||
|
return self.template_str.format(*args, **kwargs)
|