Encapsulate type guessing logic in a new Manifest method.
authorZac Medico <zmedico@gentoo.org>
Sun, 9 Apr 2006 09:00:39 +0000 (09:00 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 9 Apr 2006 09:00:39 +0000 (09:00 -0000)
svn path=/main/trunk/; revision=3106

pym/portage.py
pym/portage_manifest.py

index dc8f2c0b78e4402c3b185616038aaefc6215c5dd..5b2c278f40d4dfae61665569b1431e8e169f10a3 100644 (file)
@@ -2077,18 +2077,10 @@ def digestgen(myarchives,mysettings,db=None,overwrite=1,manifestonly=0):
        for f in myarchives:
                # the whole type evaluation is only for the case that myarchives isn't a 
                # DIST file as create() determines the type on its own
-               mytype = mf.guessType(f)
-               if mytype == "AUX":
-                       f = f[5:]
-               elif mytype is None:
-                       continue
-               myrealtype = mf.findFile(f)
-               if myrealtype != None:
-                       mytype = myrealtype
                writemsg(">>> Creating Manifest for %s\n" % mysettings["O"])
                try:
                        writemsg(">>> Adding digests for file %s\n" % f)
-                       mf.updateFileHashes(mytype, f, checkExisting=False, reuseExisting=not os.path.exists(os.path.join(mysettings["DISTDIR"], f)))
+                       mf.updateHashesGuessType(f, checkExisting=False, reuseExisting=not os.path.exists(os.path.join(mysettings["DISTDIR"], f)))
                except portage_exception.FileNotFound, e:
                        writemsg("!!! File %s doesn't exist, can't update Manifest\n" % str(e))
                        return 0
index 8cfb43a823fd099e4cb546159f2b32b07eb84243..073f7de56277eb18abae010e9685ba613180b536 100644 (file)
@@ -389,6 +389,19 @@ class Manifest(object):
                for f in self._getCpvDistfiles(cpv):
                        self.updateFileHashes("DIST", f, ignoreMissingFiles=ignoreMissingFiles)
 
+       def updateHashesGuessType(self, fname, *args, **kwargs):
+               """ Regenerate hashes for the given file (guesses the type and then
+               calls updateFileHashes)."""
+               mytype = self.guessType(fname)
+               if mytype == "AUX":
+                       fname = fname[len("files" + os.sep):]
+               elif mytype is None:
+                       return
+               myrealtype = self.findFile(fname)
+               if myrealtype is not None:
+                       mytype = myrealtype
+               return self.updateFileHashes(mytype, fname, *args, **kwargs)
+
        def getFileData(self, ftype, fname, key):
                """ Return the value of a specific (type,filename,key) triple, mainly useful
                to get the size for distfiles."""