def load(self, **kw): re_multivalue = re.compile(r'\s*,\s*') self.by_name = dict() self.by_section = dict() log.info("Loading %s...", self.datafile) with open(self.datafile, "r") as fd: for pkg in deb822.Deb822.iter_paragraphs(fd): name = pkg["Package"] src = pkg.get("Source", name) if not src: src = name section = pkg.get("Section", "unknown") section = section.split("/")[-1] desc = pkg.get("Description", None) if desc is None: continue sdesc, ldesc = utils.splitdesc(desc) def mv(name): "Get list value for multivalue field" return [x for x in re_multivalue.split(pkg.get(name, "")) if x] # Cook the source info and make a dict with what we need info = Pkg(name, pkg["Version"], src, section, sdesc, ldesc, mv("Architecture"), mv("Pre-Depends"), mv("Depends"), mv("Recommends"), mv("Suggests"), mv("Enhances"), mv("Distribution")) # Index it by various attributes self.by_name[name] = info self.by_section.setdefault(section, []).append(info)
def load(self, **kw): self.facets = dict() self.tags = dict() log.info("Loading %s...", self.datafile) with open(self.datafile, "r") as fd: for voc in deb822.Deb822.iter_paragraphs(fd): if "Facet" in voc: name = voc["Facet"] sdesc, ldesc = utils.splitdesc(voc.get("Description", None)) self.facets[name] = Facet(name, sdesc, ldesc) elif "Tag" in voc: name = voc["Tag"] if name.find("::") == -1: # Skip legacy tags continue facet = self.facets[name.split("::")[0]] sdesc, ldesc = utils.splitdesc(voc.get("Description", None)) self.tags[name] = Tag(name, facet, sdesc, ldesc) else: log.warning("Found a record in vocabulary that is neither a Facet nor a Tag")