public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dbapi/, pym/portage/util/
@ 2011-05-26  6:18 Zac Medico
  0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2011-05-26  6:18 UTC (permalink / raw
  To: gentoo-commits

commit:     36f60082668a1626c3252fdd72b917d02a3eab99
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 05:42:24 2011 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Thu May 26 06:12:38 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=36f60082

writedict: use write_atomic for exceptions

Also, fix calling code to handle InvalidLocation exceptions.

---
 pym/portage/dbapi/vartree.py |    4 +---
 pym/portage/util/__init__.py |   22 ++++++++--------------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index b7d3710..b257aac 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 60b9575..61e5e4e 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):
 	"""



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-26  6:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-26  6:18 [gentoo-commits] proj/portage:2.1.9 commit in: pym/portage/dbapi/, pym/portage/util/ Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox