In [ ]:
import os
import subprocess
from functools import partial
from utils import travis_op, apply_to_all_projects

v = '0.4.x'
working_dir = '/Users/jab08/_bump_condaci'
CONDACI_URL_START = 'https://raw.githubusercontent.com/menpo/condaci/v'


def replace_version_in_str(v, string):
    before, after = string.split(CONDACI_URL_START)
    before += CONDACI_URL_START

    old_v, after = after.split('/', 1)
    after = '/' + after
    return before + v + after


replace_version = partial(replace_version_in_str, v)
travis_bump_v = partial(travis_op, replace_version)


def bump_repo(repo_dir):
    os.chdir(repo_dir)
    did_bump_travis = travis_bump_v(repo_dir)
    if did_bump_travis:
        print(subprocess.check_output(['git', 'commit', '-am', 'bump condaci to {}'.format(v)]))
        print(subprocess.check_output(['git', 'push', 'origin', 'master']))
    else:
        print('{} is already up to date'.format(repo_dir))

In [ ]:
apply_to_all_projects(working_dir, bump_repo)