Exemplo n.º 1
0
 def search(self, *terms):
     """Don't use this. This is painfully slow."""
     desc_re = re.compile(r"%DESC%\n.*{0}.*$".format(".*".join(terms)),
                          re.IGNORECASE | re.MULTILINE)
     for db in ALPM_DB_PATH.join("sync").glob("*.db"):
         if db.name[:-3] not in self.enabled_repositories:
             continue
         seen = []
         try:
             tar = tarfile.open(db, "r")
         except tarfile.ReadError:
             log.error("could not open db file: {0}".format(db))
             continue
         for member in tar.getmembers():
             member_path = path(member.name)
             if member_path.name != "desc":
                 continue
             package = member_path.parent
             if package.name in seen:
                 continue
             desc = tar.extractfile(member).read()
             if (len(terms) == 1 and
                 re.match(terms[0], package.name, re.IGNORECASE)):
                 seen.append(package.name)
             else:
                 if re.search(desc_re, desc):
                     seen.append(package.name)
                 else:
                     continue
             metadata = self.parse_desc(desc)
             yield ALPMPackage(metadata=metadata)
Exemplo n.º 2
0
 def get_backends(self):
     backend_names = map(str.strip, self.config.backend_order.split(","))
     backends = []
     for name in backend_names:
         try:
             import_("borealis.backends." + name)
             backend = get_subclass(PackageManagementBackend,
                                    name.rsplit(":")[-1])
             if not backend:
                 raise Exception("object exists but isn't a valid backend")
             backends.append(backend(self))
         except Exception, err:
             log.error("failed to load backend {}: {}".format(name,
                       str(err)))