Make the syntax work with Python 2.4

pull/18777/head
Ales Nosek 9 years ago committed by Matt Clay
parent 90d084d82b
commit 4e787f17cf

@ -103,10 +103,13 @@ import sys
def do_ini(module, filename, section=None, option=None, value=None, state='present', backup=False): def do_ini(module, filename, section=None, option=None, value=None, state='present', backup=False):
with open(filename, 'r') as ini_file: ini_file = open(filename, 'r')
try:
ini_lines = ini_file.readlines() ini_lines = ini_file.readlines()
# append a fake section line to simplify the logic # append a fake section line to simplify the logic
ini_lines.append('[') ini_lines.append('[')
finally:
ini_file.close()
within_section = not section within_section = not section
section_start = 0 section_start = 0
@ -168,8 +171,11 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
if changed and not module.check_mode: if changed and not module.check_mode:
if backup: if backup:
module.backup_local(filename) module.backup_local(filename)
with open(filename, 'w') as ini_file: ini_file = open(filename, 'w')
try:
ini_file.writelines(ini_lines) ini_file.writelines(ini_lines)
finally:
ini_file.close()
return changed return changed

Loading…
Cancel
Save