def _validate_build(self, value): """Validate build version TOSCA version is invalid if build version is present without the qualifier. Eg: version = 18.0.0-1 is invalid. """ if not self.qualifier and value: ExceptionCollector.appendException( InvalidTOSCAVersionPropertyException(what=(self.version))) return value
def _validate_qualifier(self, value): """Validate qualifier TOSCA version is invalid if a qualifier is present without the fix version or with all of major, minor and fix version 0s. For example, the following versions are invalid 18.0.abc 0.0.0.abc """ if (self.fix_version is None and value) or \ (self.minor_version == self.major_version == self.fix_version == '0' and value): ExceptionCollector.appendException( InvalidTOSCAVersionPropertyException(what=(self.version))) return value
def __init__(self, version): self.version = str(version) match = self.VERSION_RE.match(self.version) if not match: ExceptionCollector.appendException( InvalidTOSCAVersionPropertyException(what=(self.version))) return ver = match.groupdict() if self.version in ['0', '0.0', '0.0.0']: log.warning('Version assumed as not provided') self.version = None self.minor_version = ver['minor_version'] self.major_version = ver['major_version'] self.fix_version = ver['fix_version'] self.qualifier = self._validate_qualifier(ver['qualifier']) self.build_version = self._validate_build(ver['build_version']) self._validate_major_version(self.major_version)