From: Aviv Keshet Date: Fri, 12 Apr 2013 00:51:34 +0000 (-0700) Subject: refactor contents file writing to its own function X-Git-Tag: v2.2.0_alpha174~23 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a65efb0b622bc745bbeb1a8fa4f05b1b936a761b;p=portage.git refactor contents file writing to its own function This CL refactors out the functionality of writing a contents dicionary to file. That functionality is required by a change in the chromeos chromite repository. BUG=chromium:229234 TEST=None Change-Id: I851724408b1d10827eee2ea8d67bdca9ad90c455 --- diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 9bc6e89b2..0d4a75608 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1010,12 +1010,23 @@ class vardbapi(dbapi): removed += 1 if removed: - self._bump_mtime(pkg.mycpv) - f = atomic_ofstream(os.path.join(pkg.dbdir, "CONTENTS")) - write_contents(new_contents, root, f) - f.close() - self._bump_mtime(pkg.mycpv) - pkg._clear_contents_cache() + self.writeContentsToContentsFile(pkg, new_contents) + + def writeContentsToContentsFile(self, pkg, new_contents): + """ + @param pkg: package to write contents file for + @type pkg: dblink + @param new_contents: contents to write to CONTENTS file + @type new_contents: contents dictionary of the form + {u'/path/to/file' : (contents_attribute 1, ...), ...} + """ + root = self.settings['ROOT'] + self._bump_mtime(pkg.mycpv) + f = atomic_ofstream(os.path.join(pkg.dbdir, "CONTENTS")) + write_contents(new_contents, root, f) + f.close() + self._bump_mtime(pkg.mycpv) + pkg._clear_contents_cache() class _owners_cache(object): """