From a6f5ec1a6fb97b33295b1d3960877c04ccbf9d2d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 2 Jul 2006 06:24:36 +0000 Subject: Add a new parse_use_local_desc() function. svn path=/main/trunk/; revision=3748 --- bin/repoman | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/repoman b/bin/repoman index ebd3882a5..59fbb2713 100755 --- a/bin/repoman +++ b/bin/repoman @@ -523,20 +523,34 @@ if "--pretend" in myoptions: elif quiet < 1: print green("\nRepoMan scours the neighborhood...") +def parse_use_local_desc(mylines, usedict=None): + """returns a dict of the form {cpv:set(flags)}""" + if usedict is None: + usedict = {} + lineno = 0 + for l in mylines: + lineno += 1 + if not l or l.startswith("#"): + continue + mysplit = l.split(None, 1) + if not mysplit: + continue + mysplit = mysplit[0].split(":") + if len(mysplit) != 2: + raise ParseError("line %d: Malformed input: '%s'" % \ + (lineno, l.rstrip("\n"))) + usedict.setdefault(mysplit[0], set()) + usedict[mysplit[0]].add(mysplit[1]) + return usedict + # retreive local USE list luselist={} try: - mylist=portage.grabfile(portdir+"/profiles/use.local.desc") - for mypos in range(0,len(mylist)): - mysplit=mylist[mypos].split()[0] - myuse=string.split(mysplit,":") - if len(myuse)==2: - if not luselist.has_key(myuse[0]): - luselist[myuse[0]] = [] - luselist[myuse[0]].append(myuse[1]) -except SystemExit, e: - raise # Need to propogate this -except: + f = open(os.path.join(portdir, "profiles", "use.local.desc")) + parse_use_local_desc(f, luselist) + f.close() +except (IOError, OSError, ParseError), e: + print >> sys.stderr, str(e) err("Couldn't read from use.local.desc") # setup a uselist from portage -- cgit v1.2.3-1-g7c22