use write_atomic for fixdbentries
authorZac Medico <zmedico@gentoo.org>
Sun, 12 Feb 2006 21:09:49 +0000 (21:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 12 Feb 2006 21:09:49 +0000 (21:09 -0000)
svn path=/main/trunk/; revision=2698

pym/portage.py

index 4c574b3f0a07e052240586361b9e9e1c9233465d..2b9868aca0e9d3935f6b8cf11278866bf5ced839 100644 (file)
@@ -3654,7 +3654,8 @@ def fixdbentries(old_value, new_value, dbdir):
        """python replacement for the fixdbentries script, replaces old_value
        with new_value for package names in files in dbdir."""
        for myfile in [f for f in os.listdir(dbdir) if not f == "CONTENTS"]:
-               f = open(dbdir+"/"+myfile, "r")
+               file_path = os.path.join(dbdir, myfile)
+               f = open(file_path, "r")
                mycontent = f.read()
                f.close()
                if not mycontent.count(old_value):
@@ -3664,9 +3665,7 @@ def fixdbentries(old_value, new_value, dbdir):
                mycontent = re.sub(old_value+"(\\s)", new_value+"\\1", mycontent)
                mycontent = re.sub(old_value+"(-[^a-zA-Z])", new_value+"\\1", mycontent)
                mycontent = re.sub(old_value+"([^a-zA-Z0-9-])", new_value+"\\1", mycontent)
-               f = open(dbdir+"/"+myfile, "w")
-               f.write(mycontent)
-               f.close()
+               write_atomic(file_path, mycontent)
 
 class packagetree:
        def __init__(self,virtual,clone=None):