<commit_before>import os
from contextlib import contextmanager
from datetime import datetime

from fabric.api import local
from fabric.context_managers import hide


GH_REF = 'github.com/mythmon/mythmon.com.git'
GH_TOKEN = os.environ.get('GH_TOKEN')


@contextmanager
def cd(newdir):
    print 'Entering {}/'.format(newdir)
    prevdir = os.getcwd()
    os.chdir(newdir)
    try:
        yield
    finally:
        print 'Leaving {}/'.format(newdir)
        os.chdir(prevdir)


def make_output():
    if os.path.isdir('output/.git'):
        with cd('output'):
            local('git reset --hard')
            local('git clean -fxd')
            local('git checkout gh-pages')
            local('git fetch origin')
            local('git reset --hard origin/gh-pages')
    else:
        local('rm -rf output')
        local('git clone https://{} output'.format(GH_REF))


def build():
    make_output()
    local('wok')


def publish():
    if not GH_TOKEN:
        raise Exception("Probably can't push because GH_TOKEN is blank.")
    build()

    with cd('output'):
        local('git add .')
        author = 'Tr<NAME> <<EMAIL>>'
        message = 'Travis Build'
        local('git commit --author "{}" -am "{}"'.format(author, message))

        # Hide commands, since there will be secrets.
        with hide('running'):<commit_msg>Make git work on travis.<commit_after>import os
from contextlib import contextmanager
from datetime import datetime

from fabric.api import local
from fabric.context_managers import hide


GH_REF = 'github.com/mythmon/mythmon.com.git'
GH_TOKEN = os.environ.get('GH_TOKEN')


@contextmanager
def cd(newdir):
    print 'Entering {}/'.format(newdir)
    prevdir = os.getcwd()
    os.chdir(newdir)
    try:
        yield
    finally:
        print 'Leaving {}/'.format(newdir)
        os.chdir(prevdir)


def make_output():
    if os.path.isdir('output/.git'):
        with cd('output'):
            local('git reset --hard')
            local('git clean -fxd')
            local('git checkout gh-pages')
            local('git fetch origin')
            local('git reset --hard origin/gh-pages')
    else:
        local('rm -rf output')
        local('git clone https://{} output'.format(GH_REF))


def build():
    make_output()
    local('wok')


def publish():
    if not GH_TOKEN:
        raise Exception("Probably can't push because GH_TOKEN is blank.")
    build()

    with cd('output'):
        local('git add --all .')
        local('git config user.email "<EMAIL>"')
        local('git config user.name "<NAME>"')
        local('git commit -am "Travis Build"')

        # Hide commands, since there will be secrets.
        with hide('running'):
{'fraction_non_alphanumeric': 0.13643122676579925, 'fraction_numerical': 0.0, 'mean_word_length': 2.494805194805195, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4345472', 'n_tokens_mistral': 839, 'n_tokens_neox': 814, 'n_words': 227}