Пример #1
0
    def get_reqs(self, req):
        """
        Returns a dictionary mapping all requirements found recursively
        to the distribution which requires it.
        """
        # the root requirement (in the argument) itself maps to recursion
        # level 0 and a non-existent distribution (because the required by
        # the argument of this function and not any other distribution)
        assert req.strictness == 3, req
        reqs1 = {req: (0, 'ROOT')}

        # add all requirements for the root requirement
        self.add_reqs(reqs1, req)

        if self.verbose:
            print "Requirements: (-level, strictness)"
            for r in sorted(reqs1):
                print '\t%-33r %3i %3i' % (r, -reqs1[r][0], r.strictness)

        reqs2 = {}
        for name in set(r.name for r in reqs1):
            # get all requirements for the name
            rs = []
            for r in filter_name(reqs1, name):
                # append a tuple with:
                #   * tuple(negative recursion level, strictness)
                #   * requirement itself
                #   * distribution requiring it
                rs.append(((-reqs1[r][0], r.strictness), r, reqs1[r][1]))

            rs.sort()
            r, d = rs[-1][1:]
            reqs2[r] = d

        return reqs2
Пример #2
0
    def get_reqs(self, req):
        """
        Returns a dictionary mapping all requirements found recursively
        to the distribution which requires it.
        """
        # the root requirement (in the argument) itself maps to recursion
        # level 0 and a non-existent distribution (because the required by
        # the argument of this function and not any other distribution)
        assert req.strictness == 3, req
        reqs1 = {req: (0, 'ROOT')}

        # add all requirements for the root requirement
        self.add_reqs(reqs1, req)

        if self.verbose:
            print "Requirements: (-level, strictness)"
            for r in sorted(reqs1):
                print '\t%-33r %3i %3i' % (r, -reqs1[r][0], r.strictness)

        reqs2 = {}
        for name in set(r.name for r in reqs1):
            # get all requirements for the name
            rs = []
            for r in filter_name(reqs1, name):
                # append a tuple with:
                #   * tuple(negative recursion level, strictness)
                #   * requirement itself
                #   * distribution requiring it
                rs.append(((-reqs1[r][0], r.strictness), r, reqs1[r][1]))

            rs.sort()
            r, d = rs[-1][1:]
            reqs2[r] = d

        return reqs2
Пример #3
0
 def select_new_reqs(self, reqs, dist):
     """
     Selects new requirements, which are listed as dependencies in the
     distribution 'dist', and are not already in the requirements 'reqs',
     unless the distribution requires something more strict.
     """
     result = set()
     for r in self.reqs_dist(dist):
         # from all the reqs (we already have collected) filter the
         # ones with the same project name
         rs2 = filter_name(reqs, r.name)
         if rs2:
             # if there are requirements for an existing project name,
             # only add if it is more strict
             for r2 in rs2:
                 if r2.strictness > r.strictness:
                     result.add(r2)
         else:
             # otherwise, just add it, there is no requirement for this
             # project yet
             result.add(r)
     return result
Пример #4
0
 def select_new_reqs(self, reqs, dist):
     """
     Selects new requirements, which are listed as dependencies in the
     distribution 'dist', and are not already in the requirements 'reqs',
     unless the distribution requires something more strict.
     """
     result = set()
     for r in self.reqs_dist(dist):
         # from all the reqs (we already have collected) filter the
         # ones with the same project name
         rs2 = filter_name(reqs, r.name)
         if rs2:
             # if there are requirements for an existing project name,
             # only add if it is more strict
             for r2 in rs2:
                 if r2.strictness > r.strictness:
                     result.add(r2)
         else:
             # otherwise, just add it, there is no requirement for this
             # project yet
             result.add(r)
     return result