summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/dbapi/vartree.py4
-rw-r--r--pym/portage/util/__init__.py22
2 files changed, 9 insertions, 17 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index b7d3710a3..b257aac47 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -3640,9 +3640,7 @@ class dblink(object):
cfgfiledict.pop("IGNORE", None)
try:
writedict(cfgfiledict, conf_mem_file)
- except IOError as e:
- if e.errno != errno.ENOENT:
- raise
+ except InvalidLocation:
self.settings._init_dirs()
writedict(cfgfiledict, conf_mem_file)
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 60b9575a9..61e5e4e53 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -457,20 +457,14 @@ def grablines(myfilename, recursive=0, remember_source_file=False):
def writedict(mydict,myfilename,writekey=True):
"""Writes out a dict to a file; writekey=0 mode doesn't write out
the key and assumes all values are strings, not lists."""
- myfile = None
- try:
- myfile = atomic_ofstream(myfilename)
- if not writekey:
- for x in mydict.values():
- myfile.write(x+"\n")
- else:
- for x in mydict:
- myfile.write("%s %s\n" % (x, " ".join(mydict[x])))
- myfile.close()
- except IOError:
- if myfile is not None:
- myfile.abort()
- raise
+ lines = []
+ if not writekey:
+ for v in mydict.values():
+ lines.append(v + "\n")
+ else:
+ for k, v in mydict.items():
+ lines.append("%s %s\n" % (k, " ".join(v)))
+ write_atomic(myfilename, "".join(lines))
def shlex_split(s):
"""