RepoConfig.update(): getattr/setattr loop
authorZac Medico <zmedico@gentoo.org>
Fri, 28 Oct 2011 05:30:34 +0000 (22:30 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 28 Oct 2011 05:30:34 +0000 (22:30 -0700)
pym/portage/repository/config.py

index 19c1aeb86a5a0fe1fa90446c9b212eb8cd55a931..2cc8a0bdc2db291eeca299eb040c12172a127d83 100644 (file)
@@ -161,23 +161,15 @@ class RepoConfig(object):
 
        def update(self, new_repo):
                """Update repository with options in another RepoConfig"""
-               if new_repo.aliases is not None:
-                       self.aliases = new_repo.aliases
-               if new_repo.eclass_overrides is not None:
-                       self.eclass_overrides = new_repo.eclass_overrides
-               if new_repo.masters is not None:
-                       self.masters = new_repo.masters
+
+               for k in ('aliases', 'eclass_overrides', 'location', 'masters',
+                       'name', 'priority', 'sync', 'user_location'):
+                       v = getattr(new_repo, k, None)
+                       if v is not None:
+                               setattr(self, k, v)
+
                if new_repo.name is not None:
-                       self.name = new_repo.name
                        self.missing_repo_name = new_repo.missing_repo_name
-               if new_repo.user_location is not None:
-                       self.user_location = new_repo.user_location
-               if new_repo.location is not None:
-                       self.location = new_repo.location
-               if new_repo.priority is not None:
-                       self.priority = new_repo.priority
-               if new_repo.sync is not None:
-                       self.sync = new_repo.sync
 
        @staticmethod
        def _read_valid_repo_name(repo_path):