Example #1
0
class XMLRPCRepository(RemoteRepository):
    def __init__(self, location, verbose=False):
        self.location = location
        # an empty Environment to help with tracking packages
        self.environment = Environment(search_path=[])
        self.server = Server(self.location)
        self._projects = None
        self.tmpdir = mkdtemp(prefix="ensetuptools-")
        self.verbose = verbose

    @property
    def projects(self):
        if self._projects == None:
            info("Scanning repository at %s..." % self.location)
            for project in self.server.list_packages():
                self._projects[project] = XMLRPCProject(self, project)
        return self._projects

    def search(self, combiner='and', **kwargs):
        precise_terms = dict((key, value) for key, value in kwargs
                             if isinstance(value, basestring))
        if precise_terms:
            partial_match_names = set(partial_match['name']
                                      for partial_match in
                                      self.server.search(precise_terms,
                                                         combiner))
        else:
            partial_match_names = set(self.projects)
        matches = []
        for project in partial_match_names:
            matches += self.projects[project].search(combiner, **kwargs)
        return matches