<commit_before>import os

from click import echo

from homely.utils import RepoError, RepoInfo, RepoScriptConfig


def heading(message):
    echo(message)
    echo("=" * len(message))
    echo("")


def run_update(info, pullfirst):
    assert isinstance(info, RepoInfo)
    heading("Updating from %s [%s]" % (info.localpath, info.shorthash))
    if pullfirst:
        # FIXME: warn if there are oustanding changes in the repo
        # FIXME: allow the user to configure whether they want to use 'git pull' or some other
        # command to update the repo
        echo("%s: Retrieving updates using git pull" % info.localpath)
        cmd = ['git', '-C', path, 'pull']
        subprocess.check_call(cmd)
    else:
        # FIXME: notify the user if there are oustanding changes in the repo
        pass

    # make sure the HOMELY.py script exists
    pyscript = os.path.join(info.localpath, 'HOMELY.py')
    if not os.path.exists(pyscript):
        raise RepoError("%s does not exist" % pyscript)

    global _ENGINE
    _ENGINE = Engine(info)
    from importlib.machinery import SourceFileLoader
    source = SourceFileLoader('__imported_by_homely', pyscript)
    module = source.load_module()
    _ENGINE.execute()


def clone_online_repo(repo_path):
    assert len(repo_path)
    raise Exception("TODO: git clone the repo")  # noqa
    raise Exception("TODO: return the path to the local copy of the repo")  # noqa
    # FIXME: check to see if the repo already exists locally
    # FIXME: suggest a good default location for the local clone of the repo
    return local_path


class Engine(object):
    _info = None
    _oldthings = None<commit_msg>Fix git pull<commit_after>import os

from click import echo

from homely.utils import RepoError, RepoInfo, RepoScriptConfig

import subprocess


def heading(message):
    echo(message)
    echo("=" * len(message))
    echo("")


def run_update(info, pullfirst):
    assert isinstance(info, RepoInfo)
    heading("Updating from %s [%s]" % (info.localpath, info.shorthash))
    if pullfirst:
        # FIXME: warn if there are oustanding changes in the repo
        # FIXME: allow the user to configure whether they want to use 'git pull' or some other
        # command to update the repo
        echo("%s: Retrieving updates using git pull" % info.localpath)
        cmd = ['git', 'pull']
        subprocess.check_call(cmd, cwd=info.localpath)
    else:
        # FIXME: notify the user if there are oustanding changes in the repo
        pass

    # make sure the HOMELY.py script exists
    pyscript = os.path.join(info.localpath, 'HOMELY.py')
    if not os.path.exists(pyscript):
        raise RepoError("%s does not exist" % pyscript)

    global _ENGINE
    _ENGINE = Engine(info)
    from importlib.machinery import SourceFileLoader
    source = SourceFileLoader('__imported_by_homely', pyscript)
    module = source.load_module()
    _ENGINE.execute()


def clone_online_repo(repo_path):
    assert len(repo_path)
    raise Exception("TODO: git clone the repo")  # noqa
    raise Exception("TODO: return the path to the local copy of the repo")  # noqa
    # FIXME: check to see if the repo already exists locally
    # FIXME: suggest a good default location for the local clone of the repo
    return local_path


class Engine(object):
    _info = None
    _oldthings = None
{'fraction_non_alphanumeric': 0.08627920910724984, 'fraction_numerical': 0.0, 'mean_word_length': 3.210592686002522, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '4354288', 'n_tokens_mistral': 1001, 'n_tokens_neox': 1002, 'n_words': 356}