d["MTIME"] = str(long(s.st_mtime))
d["SIZE"] = str(s.st_size)
d["MD5"] = str(md5)
+ keys = ["USE", "IUSE", "DESCRIPTION", "LICENSE", "PROVIDE", \
+ "RDEPEND", "DEPEND", "PDEPEND"]
+ from itertools import izip
+ d.update(izip(keys, self.dbapi.aux_get(cpv, keys)))
+ use = d["USE"].split()
+ iuse = set(d["IUSE"].split())
+ use = [f for f in use if f in iuse]
+ del iuse, d["IUSE"]
+ use.sort()
+ d["USE"] = " ".join(use)
+ d["DESC"] = d["DESCRIPTION"]
+ del d["DESCRIPTION"]
+ from portage.dep import paren_reduce, use_reduce, \
+ paren_normalize, paren_enclose
+ for k in "LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROVIDE":
+ deps = paren_reduce(d[k])
+ deps = use_reduce(deps, uselist=use)
+ deps = paren_normalize(deps)
+ deps = paren_enclose(deps)
+ if deps:
+ d[k] = deps
+ else:
+ del d[k]
pkgindex.packages[cpv] = d
from portage.util import atomic_ofstream
f = atomic_ofstream(os.path.join(self.pkgdir, "Packages"))
mylist = mylist + [subsec]
return mylist
+class paren_normalize(list):
+ """Take a dependency structure as returned by paren_reduce or use_reduce
+ and generate an equivalent structure that has no redundant lists."""
+ def __init__(self, src):
+ self._zap_parens(src, self)
+
+ def _zap_parens(self, src, dest, disjunction=False):
+ if not src:
+ return dest
+ i = iter(src)
+ for x in i:
+ if isinstance(x, basestring):
+ if x == '||':
+ x = i.next()
+ if len(x) == 1:
+ if isinstance(x[0], basestring):
+ dest.append(x[0])
+ else:
+ self._zap_parens(x, dest, disjunction=disjunction)
+ else:
+ dest.append("||")
+ dest.append(self._zap_parens(x, [], disjunction=True))
+ elif x.endswith("?"):
+ dest.append(x)
+ dest.append(self._zap_parens(i.next(), []))
+ else:
+ dest.append(x)
+ else:
+ if disjunction:
+ x = self._zap_parens(x, [])
+ if len(x) == 1:
+ dest.append(x[0])
+ else:
+ dest.append(x)
+ else:
+ self._zap_parens(x, dest)
+ return dest
+
def paren_enclose(mylist):
"""
Convert a list to a string with sublists enclosed with parens.