Edit a version = "1.2.3" or version="1.2.3",
        :return:
189109
def jiggle_setup_py(self):  # type: () -> int
        
        changed = 0
        setup_py = os.path.join(self.SRC, "setup.py")
        if not os.path.isfile(setup_py):
            return changed
        lines_to_write = []
        need_rewrite = False

        encoding = chardet.detect(io.open(setup_py, "rb").read())
        # logger.warning("guessing encoding " + str(encoding))
        with self.file_opener.open_this(setup_py, "r") as infile:
            for line in infile:
                leading_white = self.leading_whitespace(line)

                simplified_line = dunder_version.simplify_line(line, keep_comma=True)

                # determine if we have a version=
                version = kwarg_version.find_in_line(line)
                # setup() function args
                if version:
                    if simplified_line.strip(" \t\n").startswith(","):
                        start_comma = ","
                    else:
                        start_comma = ""

                    comma = ""
                    if simplified_line.strip(" \t\n").endswith(","):
                        comma = ","
                    # could happen, say on last.
                    # if not comma and not start_comma:
                    #     print(simplified_line)
                    #     raise TypeError("$$$$$")
                    source = '{0}{1}version = "{2}"{3}{4}\n'.format(
                        leading_white,
                        start_comma,
                        unicode(self.version_to_write()),
                        comma,
                        self.signature,
                    )
                    need_rewrite = True
                    lines_to_write.append(source)
                    continue

                # code that isn't the setup() function args
                version, version_token = dunder_version.find_in_line(line)
                if version:
                    if simplified_line.strip(" \t\n").startswith(","):
                        start_comma = ","
                    else:
                        start_comma = ""

                    # the other simplify removes ","
                    if simplified_line.strip(" \t\n").endswith(","):
                        comma = ","
                    else:
                        comma = ""

                    lines_to_write.append(
                        '{0}{1}{2} = "{3}"{4}{5}\n'.format(
                            leading_white,
                            start_comma,
                            version_token,
                            unicode(self.version_to_write()),
                            comma,
                            self.signature,
                        )
                    )
                    need_rewrite = True
                    continue

                lines_to_write.append(line)

        if need_rewrite:
            check(
                self.file_opener.open_this(setup_py, "r").read(),
                "".join(lines_to_write),
            )
            with io.open(setup_py, "w", encoding=encoding["encoding"]) as outfile:

                outfile.writelines(lines_to_write)
                outfile.close()
                changed += 1
        return changed
1106006
def get_version(version):
    """"""
    if len(version) > 2 and version[2] is not None:
        if isinstance(version[2], int):
            str_version = "%s.%s.%s" % version[:3]
        else:
            str_version = "%s.%s_%s" % version[:3]
    else:
        str_version = "%s.%s" % version[:2]

    return str_version
334150
def get_version():
    """"""
    release = get_release()
    split_version = release.split(".")
    if len(split_version) == 3:
        return ".".join(split_version[:2])
    return release
430289
def update_version_constant(version)
      if main_include && File.exist?(main_include)
        file_contents = File.read(main_include)
        if file_contents.sub!(/^(\s+VERSION\s*=\s*)[^\s].*$/) { $1 + version.to_s.inspect }
          File.open(main_include, 'w') { |f| f << file_contents }
          modified_files << main_include
        end
      end
    end
1364991
def python_version():
    ''''''
    major, minor, patch = sys.version_info[0:3]
    return '{0}.{1}.{2}'.format(major, minor, patch)
1230162
def format_version(version, build_number=None, build_tag=BUILD_TAG):
    
    formatted_version = ".".join(map(str, version))

    if build_number is not None:
        return "{formatted_version}-{build_tag}-{build_number}".format(**locals())
    
    return formatted_version
867385
def yank_version(name, version, options = {})
      ensure_ready!(:authorization)
      url = "gems/#{escape(name)}/versions/#{escape(version)}"
      response = connection.delete(url, options)
      checked_response_body(response)
    end
63052
def replace_version(self, other, logger):
        

        if other.library_name != self.library_name:
            logger.debug(
                'not replacable: {} != {} ()'
                .format(other.library_name, self.library_name, other.filename)
            )
            return False
        elif int(other.major_version) != int(self.major_version):
            logger.debug(
                'not replacable: {} != {} ({})'
                .format(
                    int(self.major_version),
                    int(other.major_version),
                    other.filename,
                )
            )
            return False
        elif float(other.minor_version) >= float(self.minor_version):
            logger.debug(
                'not replacable: {} >= {} ({})'
                .format(
                    other.minor_version,
                    self.minor_version,
                    other.filename,
                )
            )
            return False
        else:
            return True
633780
def base_version(self):
        """"""
        components = [self.xyz_version]
        if self.ver_extra:
            components.append(self.ver_extra)
        return ''.join(components)
767729
def bump_version(version, bump='patch'):
    """"""
    try:
        parts = map(int, version.split('.'))
    except ValueError:
        fail('Current version is not numeric')

    if bump == 'patch':
        parts[2] += 1
    elif bump == 'minor':
        parts[1] += 1
        parts[2] = 0
    elif bump == 'major':
        parts[0] +=1
        parts[1] = 0
        parts[2] = 0

    return '.'.join(map(str, parts))
889
def get_pretty_version(self, diff_to_increase_ratio):
        
        version = self.get_version(diff_to_increase_ratio)
        build = self.get_last_commit_hash()
        return str(version) + " (" + build + ")"
652970
def get_version(version):
    ""
    assert len(version) == 5
    assert version[3] in ('alpha', 'beta', 'rc', 'final')
    parts = 2 if version[2] == 0 else 3
    main = '.'.join(map(str, version[:parts]))
    sub = ''
    if version[3] == 'alpha' and version[4] == 0:
        git_changeset = get_git_changeset()
        if git_changeset:
            sub = '.dev%s' % git_changeset
    elif version[3] != 'final':
        mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'c'}
        sub = mapping[version[3]] + str(version[4])
    return main + sub
869277
def set_version(package_name, version_str):
    
    current_version = get_version(package_name)
    version_file_path = helpers.package_file_path('_version.py', package_name)
    version_file_content = helpers.get_file_content(version_file_path)
    version_file_content = version_file_content.replace(current_version, version_str)
    with open(version_file_path, 'w') as version_file:
        version_file.write(version_file_content)
167913
def update_product_version(id, **kwargs):
    
    content = update_product_version_raw(id, **kwargs)
    if content:
        return utils.format_json(content)
724511
def updateVersion(fname):
    
    fname=os.path.abspath(fname)
    if not os.path.exists(fname):
        print("can not update version! file doesn't exist:\n",fname)
        return
    with open(fname) as f:
        raw=f.read().split("\n")
    for i,line in enumerate(raw):
        if line.startswith("__counter__="):
            version=int(line.split("=")[1])
            raw[i]="__counter__=%d"%(version+1)
    with open(fname,'w') as f:
        f.write("\n".join(raw))
    print("upgraded version %d -> %d"%(version,version+1))
    sys.path.insert(0,os.path.dirname(fname))
    import version
    print("New version:",version.__version__)
    with open('version.txt','w') as f:
        f.write(str(version.__version__))
1260691
def patch_sys_version():
    
    if '|' in sys.version:
        sys_version = sys.version.split('|')
        sys.version = ' '.join([sys_version[0].strip(), sys_version[-1].strip()])
1264042
def _init_obo_version(self, line):
        """"""
        if line[0:14] == "format-version":
            self.format_version = line[16:-1]
        if line[0:12] == "data-version":
            self.data_version = line[14:-1]