mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 16:35:02 +01:00
This commit is contained in:
parent
f4b89ce45b
commit
f5b43cc7b4
1 changed files with 7 additions and 5 deletions
|
@ -51,8 +51,11 @@ class Config:
|
|||
if sys.version_info > (3,0):
|
||||
config.read(filepath)
|
||||
else:
|
||||
tmp_filepath = py2_parser(filepath)
|
||||
config.read(tmp_filepath.name)
|
||||
try:
|
||||
config.read(filepath)
|
||||
except configparser.ParsingError:
|
||||
tmp_filepath = py2_parser(filepath)
|
||||
config.read(tmp_filepath.name)
|
||||
return config
|
||||
|
||||
def write_config(self, filename, config):
|
||||
|
@ -249,6 +252,7 @@ class Config:
|
|||
f_out.write(line)
|
||||
|
||||
def py2_parser(filename):
|
||||
"Returns the de-dented ini file from the new format ini"
|
||||
tmp = tempfile.NamedTemporaryFile('rw')
|
||||
f_out = open(tmp.name, 'w')
|
||||
if os.path.exists(filename):
|
||||
|
@ -258,6 +262,4 @@ def py2_parser(filename):
|
|||
line = line[2:]
|
||||
f_out.write(line)
|
||||
f_out.flush()
|
||||
return tmp
|
||||
|
||||
|
||||
return tmp
|
Loading…
Add table
Reference in a new issue