From dc3b5048d2caa507b4cef8afc345dc4d3ce16e6a Mon Sep 17 00:00:00 2001 From: Alec Warner Date: Mon, 23 Jul 2007 07:30:00 +0000 Subject: Fix imports for style, slight optimization for grab* function, doc fixups. svn path=/main/trunk/; revision=7369 --- pym/portage/util.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pym/portage/util.py b/pym/portage/util.py index de0cb80b7..d10cb1d6a 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -2,12 +2,19 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ + +import os +import errno +import shlex +import stat +import string +import sys + from portage.exception import PortageException, FileNotFound, \ OperationNotPermitted, PermissionDenied, ReadOnlyFileSystem import portage.exception from portage.dep import isvalidatom -import os, errno, shlex, stat, string, sys try: import cPickle except ImportError: @@ -222,6 +229,8 @@ def grabdict(myfilename, juststrings=0, empty=0, recursive=0, incremental=1): return newdict def grabdict_package(myfilename, juststrings=0, recursive=0): + """ Does the same thing as grabdict except it validates keys + with isvalidatom()""" pkgs=grabdict(myfilename, juststrings, empty=1, recursive=recursive) # We need to call keys() here in order to avoid the possibility of # "RuntimeError: dictionary changed size during iteration" @@ -237,9 +246,7 @@ def grabfile_package(myfilename, compatlevel=0, recursive=0): pkgs=grabfile(myfilename, compatlevel, recursive=recursive) for x in range(len(pkgs)-1, -1, -1): pkg = pkgs[x] - if pkg[0] == "-": - pkg = pkg[1:] - if pkg[0] == "*": # Kill this so we can deal the "packages" file too + if pkg[0] in ["-","*"]: # -atom *pkg for packages file pkg = pkg[1:] if not isvalidatom(pkg): writemsg("--- Invalid atom in %s: %s\n" % (myfilename, pkgs[x]), -- cgit v1.2.3-1-g7c22