Updates the VERSION constant in the main include file if it exists
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
822928
def set_installed_version(vcs, version):
    
    version_path = _get_version_path(vcs)
    with open(version_path, 'w') as f:
        f.write(version)
986451
def set_version(new_version_number=None, old_version_number=''):
    
    if new_version_number is None:
        return ValueError

    import fileinput
    import sys

    file = join('timezonefinder', '__init__.py')

    for line in fileinput.input(file, inplace=1):
        if old_version_number in line:
            line = line.replace(old_version_number, new_version_number)
        sys.stdout.write(line)
1257303
def bump_minor_version():
    """"""
    version = load_version_as_list()
    print('current version: {}'.format(format_version_string(version)))
    version[-1] += 1
    print('new version: {}'.format(format_version_string(version)))

    contents = "__version__ = '{}'\n".format(format_version_string(version))

    with open(VERSION_PATH, 'w') as wfile:
        wfile.write(contents)
1129797
def update_file path, matcher, currentVersion, nextVersion
      temp_path = "#{path}.autoversion"

      begin
        File.open(path) do |source|
          File.open(temp_path, 'w') do |target|
            source.each do |line|
              if matcher.call(line)
                target.write line.gsub currentVersion.to_s, nextVersion.to_s
              else
                target.write line
              end
            end
          end
        end

        File.rename temp_path, path
      ensure
        File.unlink temp_path if File.file? temp_path
      end
    end
941468
def set_version(version, rootdir = Dir.pwd, options = {})
      exit_status = 0
      type    = (options[:type])    ? options[:type]    : FalkorLib.config[:versioning][:type]
      source  = (options[:source])  ? options[:source]  : FalkorLib.config[:versioning][:source][ type ]
      versionfile = File.join( rootdir, source[:filename] ) unless source[:filename].nil?
      major, minor, patch = major(version), minor(version), patch(version)
      #tocommit = ""
      case type
      when 'file'
        info "writing version changes in #{source[:filename]}"
        File.open(versionfile, 'w') { |f| f.puts version } #if File.exist? ( versionfile )
      when 'gem'
        info "=> writing version changes in #{source[:filename]}"
        File.open(versionfile, 'r+') do |f|
          text = f.read
          text.gsub!(/^(\s*)MAJOR\s*,\s*MINOR,\s*PATCH\s*=\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(.*)$/,
                     '\1' + "MAJOR, MINOR, PATCH = #{major}, #{minor}, #{patch}" + '\5')
          f.rewind
          f.write(text)
        end
      when 'puppet_module'
        info "=> writing version changes in #{source[:filename]}"
        metadata = JSON.parse( IO.read( versionfile ) )
        metadata["version"] = version
        File.open(versionfile, "w") do |f|
          f.write JSON.pretty_generate( metadata )
        end
        #exit 1
      end
      if FalkorLib::Git.init?(rootdir)
        filelist = FalkorLib::Git.list_files( rootdir )
        Dir.chdir( rootdir ) do
          next if source[:filename].nil?
          unless filelist.include?( source[:filename] )
            warning "The version file #{source[:filename]} is not part of the Git repository"
            answer = ask("Adding the file to the repository? (Y|n)", 'Yes')
            next if answer =~ /n.*/i
            exit_status = FalkorLib::Git.add(versionfile, "Adding the version file '#{source[:filename]}', inialized to the '#{version}' version" )
            next
          end
          run %( git diff #{source[:filename]} )
          answer = ask(cyan("=> Commit the changes of the version file to the repository? (Y|n)"), 'Yes')
          next if answer =~ /n.*/i
          run %( git commit -s -m "bump to version '#{version}'" #{source[:filename]} )
          exit_status = $?.to_i
          # if (type == 'gem' && File.exists?(File.join(rootdir, 'Gemfile')) )
          #     run %{
          #        sleep 2
          #        bundle update falkorlib
          #        git commit -s -m "Update Gemfile.lock accordingly" Gemfile.lock
          #     } if command?( 'bundle' )
          # end
        end
      end
      exit_status
    end
1295977
def update_version_module(check_name, old_ver, new_ver):
    
    version_file = get_version_file(check_name)
    contents = read_file(version_file)

    contents = contents.replace(old_ver, new_ver)
    write_file(version_file, contents)
1340990
def EnsurePythonVersion(self, major, minor):
        """"""
        if sys.version_info < (major, minor):
            v = sys.version.split()[0]
            print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v))
            sys.exit(2)
794516
def bump_version(project, source, force_init):  # type: (str, str, bool, bool) ->int
    
    file_opener = FileOpener()
    # logger.debug("Starting version jiggler...")
    jiggler = JiggleVersion(project, source, file_opener, force_init)

    logger.debug(
        "Current, next : {0} -> {1} : {2}".format(
            jiggler.current_version, jiggler.version, jiggler.schema
        )
    )
    if not jiggler.version_finder.validate_current_versions():

        logger.debug(unicode(jiggler.version_finder.all_current_versions()))
        logger.error("Versions not in sync, won't continue")
        die(-1, "Versions not in sync, won't continue")
    changed = jiggler.jiggle_all()
    logger.debug("Changed {0} files".format(changed))
    return changed
666569
def update_version_number(update_level='patch'):
    """Find current version"""
    temp_file = version_file().parent / ("~" + version_file().name)
    with open(str(temp_file), 'w') as g:
        with open(str(version_file()), 'r') as f:
            for line in f:
                version_matches = bare_version_re.match(line)
                if version_matches:
                    bare_version_str = version_matches.groups(0)[0]
                    if semantic_version.validate(bare_version_str):
                        current_version = Version(bare_version_str)
                        print("{}Current version is {}".format(" "*4, current_version))
                    else:
                        current_version = Version.coerce(bare_version_str)
                        if not text.query_yes_quit("{}I think the version is {}. Use it?".format(" "*4, current_version), default="yes"):
                            exit(Fore.RED + 'Please set an initial version number to continue')

                    """Determine new version number"""
                    if update_level is 'major':
                        current_version = current_version.next_major()
                    elif update_level is 'minor':
                        current_version = current_version.next_minor()
                    elif update_level is 'patch':
                        current_version = current_version.next_patch()
                    elif update_level is 'prerelease':
                        if not current_version.prerelease:
                            current_version = current_version.next_patch()
                            current_version.prerelease = ('dev', )
                    else:
                        exit(Fore.RED + 'Cannot update version in {} mode'.format(update_level))

                    print("{}New version is     {}".format(" "*4, current_version))

                    """Update version number"""
                    line = '__version__ = "{}"'.format(current_version)
                print(line, file=g, end="")
        print('', file=g)  # add a blank line at the end of the file
    shutil.copyfile(str(temp_file), str(version_file()))
    os.remove(str(temp_file))
    return(current_version)
73577
def main():
    """"""
    last_known = '0'
    if os.path.isfile(metafile):
        with open(metafile) as fh:
            last_known = fh.read()

    import mbed_cloud
    current = mbed_cloud.__version__

    # how significant a change in version scheme should trigger a new changelog entry
    # (api major, api minor, sdk major, sdk minor, sdk patch)
    sigfigs = 4
    current_version = LooseVersion(current).version
    last_known_version = LooseVersion(last_known).version

    should_towncrier = current_version[:sigfigs] != last_known_version[:sigfigs]

    print('%s -- %s :: current vs previous changelog build' % (current, last_known))
    if should_towncrier:
        print('%s >> %s :: running changelog build' % (current, last_known))
        subprocess.check_call(
            ['towncrier', '--yes'],
            cwd=os.path.join(PROJECT_ROOT, 'docs', 'changelog')
        )
        with open(metafile, 'w') as fh:
            fh.write(current)
1050942
def update(self):
        """"""
        for linenum in reversed(sorted(self.updates)):
            self.replace_baseline_repr(linenum, self.updates[linenum])

        if not self.TEST_MODE:
            path = '{}.update{}'.format(*os.path.splitext(self.path))
            with io.open(path, 'w', encoding='utf-8') as fh:
                fh.write('\n'.join(self.lines))
            print('UPDATE: {}'.format(self.showpath(path)))
1156511
def update(
        ctx,
        archive_name,
        bumpversion='patch',
        prerelease=None,
        dependency=None,
        message=None,
        string=False,
        file=None):
    '''
    
    '''

    _generate_api(ctx)

    args, kwargs = _parse_args_and_kwargs(ctx.args)
    assert len(args) == 0, 'Unrecognized arguments: "{}"'.format(args)

    dependencies_dict = _parse_dependencies(dependency)

    var = ctx.obj.api.get_archive(archive_name)
    latest_version = var.get_latest_version()

    if string:

        with var.open(
                'w+',
                bumpversion=bumpversion,
                prerelease=prerelease,
                dependencies=dependencies_dict,
                metadata=kwargs,
                message=message) as f:

            if file is None:
                for line in sys.stdin:
                    f.write(u(line))
            else:
                f.write(u(file))

    else:
        if file is None:
            file = click.prompt('enter filepath')

        var.update(
            file,
            bumpversion=bumpversion,
            prerelease=prerelease,
            dependencies=dependencies_dict,
            metadata=kwargs,
            message=message)

    new_version = var.get_latest_version()

    if latest_version is None and new_version is not None:
        bumpmsg = ' new version {} created.'.format(
            new_version)

    elif new_version != latest_version:
        bumpmsg = ' version bumped {} --> {}.'.format(
            latest_version, new_version)

    elif var.versioned:
        bumpmsg = ' version remains {}.'.format(latest_version)
    else:
        bumpmsg = ''

    click.echo('uploaded data to {}.{}'.format(var, bumpmsg))
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
1245003
def link_version(self, source, target):
        
        if not hasattr(target, VERSION_ID):
            # no initial version of this object!
            logger.warn("No iniatial version found for '{}'"
                        .format(repr(target)))
            return

        if not hasattr(source, REFERENCE_VERSIONS):
            source.reference_versions = {}

        target_uid = api.get_uid(target)
        # store the current version of the target on the source
        source.reference_versions[target_uid] = target.version_id
        # persist changes that occured referenced versions
        source._p_changed = 1
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__))
765373
def _ensure_dependency_available_at_version(package_name, min_version):
  """"""

  try:
    pkg = importlib.import_module(package_name)
  except ImportError:
    pip_name = package_name.replace('_', '-')
    raise SystemError(
        'Sonnet requires %s (minimum version %s) to be installed. '
        'If using pip, run `pip install %s` or '
        '`pip install %s-gpu`' % (
            package_name, min_version, pip_name, pip_name))

  installed_version = semantic_version.Version(pkg.__version__)
  version_spec = semantic_version.Spec('>=' + min_version)
  if not version_spec.match(installed_version):
    raise SystemError(
        '%s version %s is installed, but Sonnet requires at least version %s.' %
        (package_name, pkg.__version__, min_version))