Package.operation: eliminate duplicate code
authorZac Medico <zmedico@gentoo.org>
Wed, 22 Dec 2010 19:35:29 +0000 (11:35 -0800)
committerZac Medico <zmedico@gentoo.org>
Wed, 22 Dec 2010 19:35:29 +0000 (11:35 -0800)
pym/_emerge/Package.py

index 009808f5ffa54f7367ad20e6afff92c071fff463..0b3375edc661640c5d817e33a86280ad14796bb8 100644 (file)
@@ -73,6 +73,11 @@ class Package(Task):
                self._validate_deps()
                self.masks = self._masks()
                self.visible = self._visible(self.masks)
+               if self.operation is None:
+                       if self.onlydeps or self.installed:
+                               self.operation = "nomerge"
+                       else:
+                               self.operation = "merge"
 
        def _validate_deps(self):
                """
@@ -273,11 +278,6 @@ class Package(Task):
                msgs.append(msg)
 
        def __str__(self):
-               if self.operation is None:
-                       self.operation = "merge"
-                       if self.onlydeps or self.installed:
-                               self.operation = "nomerge"
-
                if self.operation == "merge":
                        if self.type_name == "binary":
                                cpv_color = "PKG_BINARY_MERGE"
@@ -416,10 +416,6 @@ class Package(Task):
        def _get_hash_key(self):
                hash_key = getattr(self, "_hash_key", None)
                if hash_key is None:
-                       if self.operation is None:
-                               self.operation = "merge"
-                               if self.onlydeps or self.installed:
-                                       self.operation = "nomerge"
                        # For installed (and binary) packages we don't care for the repo
                        # when it comes to hashing, because there can only be one cpv.
                        # So overwrite the repo_key with type_name.