@classmethod
    def from_string(cls, version_string):
        mod = 0
        bump_patch_level = False
        if version_string.endswith("+"):
            version_string = version_string[0:-1]
            mod = 1
        elif version_string.endswith("-pre-"):
            version_string = version_string[0:-5]
            mod = -1
        elif version_string.endswith("-"):
            version_string = version_string[0:-1]
            mod = -1
        # Deal with '-rcX' substrings
        if '-rc' in version_string:
            version_string = version_string[0:version_string.find('-rc')]
            mod = -1
        # Deal with git describe generated substrings
        elif '-' in version_string:
            version_string = version_string[0:version_string.find('-')]
            mod = -1
            bump_patch_level = True


        version = [int(part) for part in version_string.split(".")]
        version = cls._padded(version, 3)
        # Make from_string and from_version_array agree. For example:
        # MongoDB Enterprise > db.runCommand('buildInfo').versionArray
        # [ 3, 2, 1, -100 ]
        # MongoDB Enterprise > db.runCommand('buildInfo').version
        # 3.2.0-97-g1ef94fe
        if bump_patch_level:
            version[-1] += 1
        version.append(mod)

        return Version(*version)
dataset/ETHPy150Open mongodb/mongo-python-driver/test/version.py/Version.from_string/original