(new_version, old_version)
Upgrade the Python version of all test environments.

    \b
    `$ ddev meta scripts upgrade-python 3.8`
Upgrade the Python version of all test environments.
Upgrade the Python version of all test environments .
def upgrade_python(new_version, old_version):
    """Upgrade the Python version of all test environments.

    \b
    `$ ddev meta scripts upgrade-python 3.8`
    """
    root = get_root()

    new_version = version_string_to_int(new_version)
    old_version = version_string_to_int(old_version) if old_version else new_version - 1

    # Examples:
    #
    # basepython = py37
    # py{27,37}: e2e ready
    # py37-{10,11}
    tox_pattern = re.compile(br'\s+py[{,\d]*(?P<old_version>%d)' % old_version, re.MULTILINE)
    replacer = get_replacer(new_version)

    files_changed = 0
    for check_dir in resolve_dir_contents(root):
        tox_file = path_join(check_dir, 'tox.ini')
        if not file_exists(tox_file):
            continue

        original_tox_contents = read_file_binary(tox_file)
        new_tox_contents = tox_pattern.sub(replacer, original_tox_contents)

        if new_tox_contents != original_tox_contents:
            files_changed += 1
            write_file_binary(tox_file, new_tox_contents)

    echo_success(f'Updated {files_changed} files')
def upgrade_python ( new_version , old_version ) : root = get_root ( ) new_version = version_string_to_int ( new_version ) old_version = version_string_to_int ( old_version ) if old_version else new_version - 1 # Examples: # # basepython = py37 # py{27,37}: e2e ready # py37-{10,11} tox_pattern = re . compile ( br'\s+py[{,\d]*(?P<old_version>%d)' % old_version , re . MULTILINE ) replacer = get_replacer ( new_version ) files_changed = 0 for check_dir in resolve_dir_contents ( root ) : tox_file = path_join ( check_dir , 'tox.ini' ) if not file_exists ( tox_file ) : continue original_tox_contents = read_file_binary ( tox_file ) new_tox_contents = tox_pattern . sub ( replacer , original_tox_contents ) if new_tox_contents != original_tox_contents : files_changed += 1 write_file_binary ( tox_file , new_tox_contents ) echo_success ( f'Updated {files_changed} files' )