You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
844 B
Python
35 lines
844 B
Python
4 years ago
|
from configparser import ConfigParser as CP
|
||
|
from io import StringIO
|
||
|
|
||
|
|
||
|
class ConfigParser(CP):
|
||
|
'''
|
||
|
ConfigParser class with to_string method to convert config to string
|
||
|
and write it inside jinja template and read methods which return
|
||
|
self object
|
||
|
'''
|
||
|
|
||
|
def to_string(self):
|
||
|
io = StringIO()
|
||
|
self.write(io)
|
||
|
return io.getvalue()
|
||
|
|
||
|
def read(self, *args, **kwards):
|
||
|
super().read(*args, **kwards)
|
||
|
return self
|
||
|
|
||
|
def read_dict(self, *args, **kwards):
|
||
|
super().read_dict(*args, **kwards)
|
||
|
return self
|
||
|
|
||
|
def read_file(self, *args, **kwards):
|
||
|
super().read_file(*args, **kwards)
|
||
|
return self
|
||
|
|
||
|
def read_string(self, *args, **kwards):
|
||
|
super().read_string(*args, **kwards)
|
||
|
return self
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.to_string()
|