(cls, version_string, partial=False, coerce=False)
return (major, minor, patch, prerelease, build)
Parse a version string into a Version() object.

        Args:
            version_string (str), the version string to parse
            partial (bool), whether to accept incomplete input
            coerce (bool), whether to try to map the passed in string into a
                valid Version.
Parse a version string into a Version() object.
Parse a version string into a Version () object .
def parse(cls, version_string, partial=False, coerce=False):
        """Parse a version string into a Version() object.

        Args:
            version_string (str), the version string to parse
            partial (bool), whether to accept incomplete input
            coerce (bool), whether to try to map the passed in string into a
                valid Version.
        """
        if not version_string:
            raise ValueError('Invalid empty version string: %r' % version_string)

        if partial:
            version_re = cls.partial_version_re
        else:
            version_re = cls.version_re

        match = version_re.match(version_string)
        if not match:
            raise ValueError('Invalid version string: %r' % version_string)

        major, minor, patch, prerelease, build = match.groups()

        if _has_leading_zero(major):
            raise ValueError("Invalid leading zero in major: %r" % version_string)
        if _has_leading_zero(minor):
            raise ValueError("Invalid leading zero in minor: %r" % version_string)
        if _has_leading_zero(patch):
            raise ValueError("Invalid leading zero in patch: %r" % version_string)

        major = int(major)
        minor = cls._coerce(minor, partial)
        patch = cls._coerce(patch, partial)

        if prerelease is None:
            if partial and (build is None):
                # No build info, strip here
                return (major, minor, patch, None, None)
            else:
                prerelease = ()
        elif prerelease == '':
            prerelease = ()
        else:
            prerelease = tuple(prerelease.split('.'))
            cls._validate_identifiers(prerelease, allow_leading_zeroes=False)

        if build is None:
            if partial:
                build = None
            else:
                build = ()
        elif build == '':
            build = ()
        else:
            build = tuple(build.split('.'))
            cls._validate_identifiers(build, allow_leading_zeroes=True)

        return (major, minor, patch, prerelease, build)
def parse ( cls , version_string , partial = False , coerce = False ) : if not version_string : raise ValueError ( 'Invalid empty version string: %r' % version_string ) if partial : version_re = cls . partial_version_re else : version_re = cls . version_re match = version_re . match ( version_string ) if not match : raise ValueError ( 'Invalid version string: %r' % version_string ) major , minor , patch , prerelease , build = match . groups ( ) if _has_leading_zero ( major ) : raise ValueError ( "Invalid leading zero in major: %r" % version_string ) if _has_leading_zero ( minor ) : raise ValueError ( "Invalid leading zero in minor: %r" % version_string ) if _has_leading_zero ( patch ) : raise ValueError ( "Invalid leading zero in patch: %r" % version_string ) major = int ( major ) minor = cls . _coerce ( minor , partial ) patch = cls . _coerce ( patch , partial ) if prerelease is None : if partial and ( build is None ) : # No build info, strip here return ( major , minor , patch , None , None ) else : prerelease = ( ) elif prerelease == '' : prerelease = ( ) else : prerelease = tuple ( prerelease . split ( '.' ) ) cls . _validate_identifiers ( prerelease , allow_leading_zeroes = False ) if build is None : if partial : build = None else : build = ( ) elif build == '' : build = ( ) else : build = tuple ( build . split ( '.' ) ) cls . _validate_identifiers ( build , allow_leading_zeroes = True ) return ( major , minor , patch , prerelease , build )