summaryrefslogtreecommitdiffstats
path: root/ipapython
diff options
context:
space:
mode:
authorChristian Heimes <cheimes@redhat.com>2015-07-14 13:18:55 +0200
committerTomas Babej <tbabej@redhat.com>2015-07-14 13:59:31 +0200
commit18d417e981045830f5dd359cf912caf3b0b9e6d3 (patch)
tree7a1ebadb49d494f1bf8c23e435cf53f45e7e46d4 /ipapython
parent35e219f996b933c8f9a5e5624bbffd6174f4c55c (diff)
downloadfreeipa-18d417e981045830f5dd359cf912caf3b0b9e6d3.tar.gz
freeipa-18d417e981045830f5dd359cf912caf3b0b9e6d3.tar.xz
freeipa-18d417e981045830f5dd359cf912caf3b0b9e6d3.zip
Replace file() with open()
The open() function is the recommended way to open a file. In Python 3 the file type is gone, but open() still works the same. The patch is related to https://fedorahosted.org/freeipa/ticket/5127 Reviewed-By: Tomas Babej <tbabej@redhat.com>
Diffstat (limited to 'ipapython')
-rw-r--r--ipapython/sysrestore.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/ipapython/sysrestore.py b/ipapython/sysrestore.py
index 580df9a4f..c058ff7c0 100644
--- a/ipapython/sysrestore.py
+++ b/ipapython/sysrestore.py
@@ -93,9 +93,8 @@ class FileStore:
for (key, value) in self.files.items():
p.set('files', key, str(value))
- f = file(self._index, "w")
- p.write(f)
- f.close()
+ with open(self._index, "w") as f:
+ p.write(f)
def backup_file(self, path):
"""Create a copy of the file at @path - so long as a copy
@@ -354,9 +353,8 @@ class StateFile:
for (key, value) in self.modules[module].items():
p.set(module, key, str(value))
- f = file(self._path, "w")
- p.write(f)
- f.close()
+ with open(self._path, "w") as f:
+ p.write(f)
def backup_state(self, module, key, value):
"""Backup an item of system state from @module, identified