Parse a Semantic Version string into is component parts.

    Args:
        text (str): A text string to parse into semver components. This string has whitespace and leading 'v'
        characters stripped off of it.

    Examples:
        Parse a string into it semvar parts::

            parts = parseSemver('v1.2.3')

    Returns:
        dict: The dictionary will contain the keys 'major', 'minor' and 'patch' pointing to integer values.
        The dictionary may also contain keys for 'build' and 'pre' information if that data is parsed out
        of a semver string. None is returned if the string is not a valid Semver string.

def parseSemver(text):
    '''
    Parse a Semantic Version string into is component parts.

    Args:
        text (str): A text string to parse into semver components. This string has whitespace and leading 'v'
        characters stripped off of it.

    Examples:
        Parse a string into it semvar parts::

            parts = parseSemver('v1.2.3')

    Returns:
        dict: The dictionary will contain the keys 'major', 'minor' and 'patch' pointing to integer values.
        The dictionary may also contain keys for 'build' and 'pre' information if that data is parsed out
        of a semver string. None is returned if the string is not a valid Semver string.
    '''
    # eat whitespace and leading chars common on version strings
    txt = text.strip().lstrip('vV')
    ret = {}

    m = semver_re.match(txt)
    if not m:
        return None
    d = m.groupdict()
    ret['major'] = int(d.get('maj'))
    ret['minor'] = int(d.get('min'))
    ret['patch'] = int(d.get('pat'))

    pre = d.get('pre')
    bld = d.get('bld')

    if pre:
        # Validate pre
        parts = pre.split('.')
        for part in parts:
            if not part:
                return None
            try:
                int(part)
            except ValueError:
                continue
            else:
                if part[0] == '0' and len(part) > 1:
                    return None
        ret['pre'] = pre

    if bld:
        # Validate bld
        parts = bld.split('.')
        for part in parts:
            if not part:
                return None
        ret['build'] = bld

    return ret