コード例 #1
0
    def is_equal(self, other):
        """
        Return true if the other version is equal to version in this dep.

        :paramtype other: string
        """
        return self.parsed_version == parse_epoch_version(other)
コード例 #2
0
    def is_lower(self, other):
        """
        Return true if version in this dep is lower than the other version.

        :paramtype other: string
        """
        return self.parsed_version < parse_epoch_version(other)
コード例 #3
0
    def is_lower(self, other):
        """
        Return true if version in this dep is lower than the other version.

        :paramtype other: string
        """
        return self.parsed_version < parse_epoch_version(other)
コード例 #4
0
    def is_equal(self, other):
        """
        Return true if the other version is equal to version in this dep.

        :paramtype other: string
        """
        return self.parsed_version == parse_epoch_version(other)
コード例 #5
0
def dependency_filter(type, queryset, value):
    m = models.Dependency.DEPENDENCY_PARSER.match(value)
    if not m:
        raise FieldError('Unrecognized value for filter for {}'.format(type))

    groups = m.groupdict()
    name = groups['name']
    op = groups['op']
    version = groups['version']

    queryset = queryset.filter(dependency__name=name,
                               dependency__type=type).distinct()

    if not version:
        return queryset

    version = parse_epoch_version(version)
    matches = dependency_predicate(op, version)
    deps = models.Dependency.objects.filter(type=type, name=name)

    for dep in deps:
        dep_version = dep.parsed_version
        if dep_version is not None and not matches(dep.comparison,
                                                   dep_version):
            queryset = queryset.exclude(pk=dep.rpm_id)

    return queryset
コード例 #6
0
    def is_satisfied_by(self, other):
        """
        Check if other version satisfies this dependency.

        :paramtype other: string
        """
        funcs = {
            '=': lambda x: x == self.parsed_version,
            '<': lambda x: x < self.parsed_version,
            '<=': lambda x: x <= self.parsed_version,
            '>': lambda x: x > self.parsed_version,
            '>=': lambda x: x >= self.parsed_version,
        }
        return funcs[self.comparison](parse_epoch_version(other))
コード例 #7
0
    def is_satisfied_by(self, other):
        """
        Check if other version satisfies this dependency.

        :paramtype other: string
        """
        funcs = {
            '=': lambda x: x == self.parsed_version,
            '<': lambda x: x < self.parsed_version,
            '<=': lambda x: x <= self.parsed_version,
            '>': lambda x: x > self.parsed_version,
            '>=': lambda x: x >= self.parsed_version,
        }
        return funcs[self.comparison](parse_epoch_version(other))
コード例 #8
0
 def parsed_version(self):
     if not hasattr(self, '_version'):
         self._version = parse_epoch_version(self.version)
     return self._version
コード例 #9
0
 def sort_key(self):
     return (self.epoch, parse_epoch_version(self.version), parse_epoch_version(self.release))
コード例 #10
0
 def parsed_version(self):
     if not hasattr(self, '_version'):
         self._version = parse_epoch_version(self.version)
     return self._version
コード例 #11
0
 def sort_key(self):
     return (self.epoch, parse_epoch_version(self.version), parse_epoch_version(self.release))