Atom: add a with_repo method for adding a repo
authorZac Medico <zmedico@gentoo.org>
Fri, 23 Sep 2011 00:47:48 +0000 (17:47 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Sep 2011 00:47:48 +0000 (17:47 -0700)
pym/portage/dep/__init__.py

index 89b6f15475f4e6c2e09068533a04ea3498a12791..5bb6becdb7d2646b5cfe5673dc557c8f175b1e73 100644 (file)
@@ -1216,6 +1216,18 @@ class Atom(_atom_base):
                return Atom(self.replace(_slot_separator + self.slot, '', 1),
                        allow_repo=True, allow_wildcard=True)
 
+       def with_repo(self, repo):
+               if self.slot is None:
+                       atom = self
+               else:
+                       atom = remove_slot(self)
+               if self.slot is not None:
+                       atom += _slot_separator + slot
+               atom += _repo_separator + repo
+               if self.use is not None:
+                       atom += str(self.use)
+               return Atom(atom, allow_repo=True, allow_wildcard=True)
+
        def with_slot(self, slot):
                atom = remove_slot(self) + _slot_separator + slot
                if self.repo is not None: