tools/android/sdk_updater/update_sdk.py
def UpdateInstanceId(package,
                     deps_path,
                     dry_run,
                     new_instance_id,
                     release_version=None):
  """Find the sdk pkg version in DEPS and modify it as cipd uploading version.

  TODO(shenghuazhang): use DEPS edition operations after issue crbug.com/760633
  fixed.

  DEPS file hooks sdk package with version with suffix -crX, e.g. '26.0.2-cr1'.
  If pkg_version is the base number of the existing version in DEPS, e.g.
  '26.0.2', return '26.0.2-cr2' as the version uploading to CIPD. If not the
  base number, return ${pkg_version}-cr0.

  Args:
    package: The name of the package.
    deps_path: Path to deps file which gclient hooks sdk pkg w/ versions.
    dry_run: Bool. To show what packages would be created and packages, without
      actually doing either.
    new_instance_id: New instance ID after CIPD package created.
    release_version: Android sdk release version e.g. 'o_mr1', 'p'.
  """
  var_package = package
  if release_version:
    var_package = release_version + '_' + var_package
  package_var_pattern = re.compile(
      # Match the argument with "'android_sdk_*_version': '" with whitespaces.
      r'(^\s*\'android_sdk_%s_version\'\s*:\s*\')' % var_package +
      # instance ID e.g. DLK621q5_Bga5EsOr7cp6bHWWxFKx6UHLu_Ix_m3AckC.
      r'([-\w.]+)'
      # End of string
      r'(\',?$)')

  with tempfile.NamedTemporaryFile() as temp_file:
    with open(deps_path) as f:
      for line in f:
        new_line = line
        found = re.match(package_var_pattern, line)
        if found:
          instance_id = found.group(2)
          new_line = re.sub(package_var_pattern,
                            r'\g<1>%s\g<3>' % new_instance_id, line)
          print(
              '    Note: deps file "%s" argument ' % deps_path +
              '"%s" would be updated to "%s".' % (instance_id, new_instance_id))
        temp_file.write(new_line)

    if not dry_run:
      temp_file.flush()
      shutil.move(temp_file.name, deps_path)
      temp_file.delete = False
Find the sdk pkg version in DEPS and modify it as cipd uploading version.

  TODO(shenghuazhang): use DEPS edition operations after issue crbug.com/760633
  fixed.

  DEPS file hooks sdk package with version with suffix -crX, e.g. '26.0.2-cr1'.
  If pkg_version is the base number of the existing version in DEPS, e.g.
  '26.0.2', return '26.0.2-cr2' as the version uploading to CIPD. If not the
  base number, return ${pkg_version}-cr0.

  Args:
    package: The name of the package.
    deps_path: Path to deps file which gclient hooks sdk pkg w/ versions.
    dry_run: Bool. To show what packages would be created and packages, without
      actually doing either.
    new_instance_id: New instance ID after CIPD package created.
    release_version: Android sdk release version e.g. 'o_mr1', 'p'.
  
Find the sdk pkg version in DEPS and modify it as cipd uploading version.

DEPS file hooks sdk package with version with suffix -crX, e.g.
Find the sdk pkg version in DEPS and modify it as cipd uploading version . DEPS file hooks sdk package with version with suffix - crX e . g .
def UpdateInstanceId(package,
                     deps_path,
                     dry_run,
                     new_instance_id,
                     release_version=None):
  var_package = package
  if release_version:
    var_package = release_version + '_' + var_package
  package_var_pattern = re.compile(
      r'(^\s*\'android_sdk_%s_version\'\s*:\s*\')' % var_package +
      r'([-\w.]+)'
      r'(\',?$)')
  with tempfile.NamedTemporaryFile() as temp_file:
    with open(deps_path) as f:
      for line in f:
        new_line = line
        found = re.match(package_var_pattern, line)
        if found:
          instance_id = found.group(2)
          new_line = re.sub(package_var_pattern,
                            r'\g<1>%s\g<3>' % new_instance_id, line)
          print(
              '    Note: deps file "%s" argument ' % deps_path +
              '"%s" would be updated to "%s".' % (instance_id, new_instance_id))
        temp_file.write(new_line)
    if not dry_run:
      temp_file.flush()
      shutil.move(temp_file.name, deps_path)
      temp_file.delete = False
def UpdateInstanceId ( package , deps_path , dry_run , new_instance_id , release_version = None ) : var_package = package if release_version : var_package = release_version + '_' + var_package package_var_pattern = re . compile ( r'(^\s*\'android_sdk_%s_version\'\s*:\s*\')' % var_package + r'([-\w.]+)' r'(\',?$)' ) with tempfile . NamedTemporaryFile ( ) as temp_file : with open ( deps_path ) as f : for line in f : new_line = line found = re . match ( package_var_pattern , line ) if found : instance_id = found . group ( 2 ) new_line = re . sub ( package_var_pattern , r'\g<1>%s\g<3>' % new_instance_id , line ) print ( '    Note: deps file "%s" argument ' % deps_path + '"%s" would be updated to "%s".' % ( instance_id , new_instance_id ) ) temp_file . write ( new_line ) if not dry_run : temp_file . flush ( ) shutil . move ( temp_file . name , deps_path ) temp_file . delete = False
Find the sdk pkg version in DEPS and modify it as cipd uploading version.
Find the sdk pkg version in DEPS and modify it as cipd uploading version .
"""Find the sdk pkg version in DEPS and modify it as cipd uploading version.

  TODO(shenghuazhang): use DEPS edition operations after issue crbug.com/760633
  fixed.

  DEPS file hooks sdk package with version with suffix -crX, e.g. '26.0.2-cr1'.
  If pkg_version is the base number of the existing version in DEPS, e.g.
  '26.0.2', return '26.0.2-cr2' as the version uploading to CIPD. If not the
  base number, return ${pkg_version}-cr0.

  Args:
    package: The name of the package.
    deps_path: Path to deps file which gclient hooks sdk pkg w/ versions.
    dry_run: Bool. To show what packages would be created and packages, without
      actually doing either.
    new_instance_id: New instance ID after CIPD package created.
    release_version: Android sdk release version e.g. 'o_mr1', 'p'.
  """ # Match the argument with "'android_sdk_*_version': '" with whitespaces. # instance ID e.g. DLK621q5_Bga5EsOr7cp6bHWWxFKx6UHLu_Ix_m3AckC. # End of string
package
The name of the package.
The name of the package .
deps_path
Path to deps file which gclient hooks sdk pkg w/ versions.
Path to deps file which gclient hooks sdk pkg w / versions .
dry_run
Bool. To show what packages would be created and packages, without
actually doing either.
Bool . To show what packages would be created and packages without actually doing either .
new_instance_id
New instance ID after CIPD package created.
New instance ID after CIPD package created .
release_version
Android sdk release version e.g.
Android sdk release version e . g .