mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
create new file if not already present
This commit is contained in:
parent
a44bb73a2f
commit
7697eee393
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Edit ini files
|
||||
|
||||
:maintainer: <ageeleshwar.kandavelu@csscorp.com>
|
||||
:maintainer: <akilesh1597@gmail.com>
|
||||
:maturity: new
|
||||
:depends: re
|
||||
:platform: all
|
||||
@ -280,11 +280,9 @@ class _Ini(object):
|
||||
with open(self.file_name, 'r') as inifile:
|
||||
previous_line = None
|
||||
for line in inifile.readlines():
|
||||
|
||||
# Make sure the empty lines between options are preserved
|
||||
if _Ini.isempty(previous_line) and not _Ini.isnewsection(line):
|
||||
current_section.append('\n')
|
||||
|
||||
if _Ini.iscomment(line):
|
||||
current_section.append(_Ini.decrypt_comment(line))
|
||||
elif _Ini.isnewsection(line):
|
||||
@ -293,7 +291,6 @@ class _Ini(object):
|
||||
elif _Ini.isoption(line):
|
||||
current_section.append(_Ini.decrypt_option(line))
|
||||
previous_line = line
|
||||
return self
|
||||
|
||||
def flush(self):
|
||||
with open(self.file_name, 'w') as outfile:
|
||||
@ -386,6 +383,10 @@ class _Ini(object):
|
||||
@staticmethod
|
||||
def get_ini_file(file_name):
|
||||
try:
|
||||
return _Ini(file_name).refresh()
|
||||
inifile = _Ini(file_name)
|
||||
inifile.refresh()
|
||||
return inifile
|
||||
except IOError:
|
||||
return inifile
|
||||
except Exception:
|
||||
return
|
||||
|
@ -3,7 +3,7 @@
|
||||
Manage ini files
|
||||
================
|
||||
|
||||
:maintainer: <ageeleshwar.kandavelu@csscorp.com>
|
||||
:maintainer: <akilesh1597@gmail.com>
|
||||
:maturity: new
|
||||
:depends: re
|
||||
:platform: all
|
||||
|
Loading…
Reference in New Issue
Block a user