Exemplo n.º 1
0
def load_version(version_file: str = VERSION_FILE) -> PlenumVersion:
    with open(version_file, 'r') as _f:
        version = json.load(_f)
        if not isinstance(version, collections.abc.Iterable):
            raise InvalidVersionError(
                "Failed to load from {}: data '{}' is not iterable".format(
                    version_file, version))
        return PlenumVersion('.'.join([str(i) for i in version if str(i)]))
Exemplo n.º 2
0
    def __init__(self,
                 version: str,
                 keep_tilde: bool = False,
                 upstream_cls: Type[Union[SourceVersion,
                                          None]] = GenericVersion):
        parsed = self._parse(version, keep_tilde, upstream_cls)
        if not parsed[1]:
            raise InvalidVersionError(
                "{} is not a valid debian version".format(version))

        self._version = version
        self._epoch, self._upstream, self._revision = parsed
Exemplo n.º 3
0
        def __init__(self, version: str, **kwargs):
            super().__init__(version, **kwargs)

            # additional restrictions
            if self._version.pre:
                if self._version.pre[0] != 'rc':
                    raise InvalidVersionError(
                        "pre-release phase '{}' is unexpected".format(
                            self._version.pre[0]))

            if self._version.post:
                raise InvalidVersionError("post-release is unexpected")

            if self._version.epoch:
                raise InvalidVersionError("epoch is unexpected")

            if self._version.local:
                raise InvalidVersionError("local version part is unexpected")

            # TODO set constraint to 3 only once new release logic becomes completed
            if len(self.release_parts) not in (2, 3):
                # TODO and here
                raise InvalidVersionError(
                    "release part should contain only 2 or 3 parts")
Exemplo n.º 4
0
 def parse(self, val):
     try:
         return int(val)
     except ValueError:
         raise InvalidVersionError()