Skip to content

Commit

Permalink
Clean up exceptions and stop passing a mutable
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch45 committed Jan 3, 2014
1 parent f8cc172 commit 6d9986f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions salt/modules/ini_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __virtual__():
option_regexp2 = re.compile(r'\s*(.+)\s*(:)\s*(.+)\s*')


def set_option(file_name, sections={}, summary=True):
def set_option(file_name, sections=None, summary=True):
'''
Edit ini files
file_name: path of ini_file
Expand All @@ -49,6 +49,8 @@ def set_option(file_name, sections={}, summary=True):
salt '*' ini.set_option /path/to/ini '{section_foo: {key: value}}'
'''
if sections is None:
sections = {}
ret = {'file_name': file_name}
inifile = _Ini.get_ini_file(file_name)
if not inifile:
Expand All @@ -75,7 +77,7 @@ def set_option(file_name, sections={}, summary=True):
if not summary:
changes[section].update({option:
sections[section][option]})
except:
except Exception:
ret.update({'error':
'while setting option {0} in section {0}'.
format(option, section)})
Expand Down Expand Up @@ -212,7 +214,7 @@ def contents(self):
for item in self:
try:
contents.update({item.name: item.value})
except:
except Exception:
pass # item was a comment
return contents

Expand Down Expand Up @@ -349,5 +351,5 @@ def isoption(line):
def get_ini_file(file_name):
try:
return _Ini(file_name).refresh()
except:
except Exception:
return

0 comments on commit 6d9986f

Please sign in to comment.