grabdict_package: use recursive name for errors
authorZac Medico <zmedico@gentoo.org>
Tue, 27 Aug 2013 19:28:44 +0000 (12:28 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 27 Aug 2013 19:30:45 +0000 (12:30 -0700)
This will fix bug #482650.

pym/portage/util/__init__.py

index 92a218793e49a4b5946c4f9fdf40ecebb213811e..264e093bc750abbc2aafd98a7d73f219bfbc7aaf 100644 (file)
@@ -428,24 +428,35 @@ def grabdict_package(myfilename, juststrings=0, recursive=0, allow_wildcard=Fals
        verify_eapi=False, eapi=None):
        """ Does the same thing as grabdict except it validates keys
            with isvalidatom()"""
-       pkgs=grabdict(myfilename, juststrings, empty=1, recursive=recursive)
-       if not pkgs:
-               return pkgs
-       if verify_eapi and eapi is None:
-               eapi = read_corresponding_eapi_file(myfilename)
 
-       # We need to call keys() here in order to avoid the possibility of
-       # "RuntimeError: dictionary changed size during iteration"
-       # when an invalid atom is deleted.
+       if recursive:
+               file_list = _recursive_file_list(myfilename)
+       else:
+               file_list = [myfilename]
+
        atoms = {}
-       for k, v in pkgs.items():
-               try:
-                       k = Atom(k, allow_wildcard=allow_wildcard, allow_repo=allow_repo, eapi=eapi)
-               except InvalidAtom as e:
-                       writemsg(_("--- Invalid atom in %s: %s\n") % (myfilename, e),
-                               noiselevel=-1)
-               else:
-                       atoms[k] = v
+       for filename in file_list:
+               d = grabdict(filename, juststrings=False,
+                       empty=True, recursive=False, incremental=True)
+               if not d:
+                       continue
+               if verify_eapi and eapi is None:
+                       eapi = read_corresponding_eapi_file(myfilename)
+
+               for k, v in d.items():
+                       try:
+                               k = Atom(k, allow_wildcard=allow_wildcard,
+                                       allow_repo=allow_repo, eapi=eapi)
+                       except InvalidAtom as e:
+                               writemsg(_("--- Invalid atom in %s: %s\n") % (filename, e),
+                                       noiselevel=-1)
+                       else:
+                               atoms.setdefault(k, []).extend(v)
+
+       if juststrings:
+               for k, v in atoms.items():
+                       atoms[k] = " ".join(v)
+
        return atoms
 
 def grabfile_package(myfilename, compatlevel=0, recursive=0, allow_wildcard=False, allow_repo=False,