<commit_before>import hashlib
import os
import urllib2

from invoke import task, run


def download(url, hash, path):
    resp = urllib2.urlopen(url)
    content = resp.read()
    content_hash = hashlib.sha256(content).hexdigest()
    assert hash == content_hash

    with open(path, "wb") as fp:
        fp.write(content)


@task(aliases=["install-nacl"])
def install_nacl(library):
    def _install_libsodium():
        tarball_path = os.path.expanduser("~/libsodium-0.2.tar.gz")

        # Download libsodium and verify it's hash
        download(
            "http://download.dnscrypt.org/libsodium/releases/libsodium-0.2.tar.gz",
            "e99a6b69adc080a5acf6b8a49fdc74b61d6f3579b590e85c93446a8325dde100",
            tarball_path,
        )

        curdir = os.getcwd()
        try:
            os.chdir(os.path.expanduser("~/"))

            # Unpack the tarball
            run("tar xf libsodium-0.2.tar.gz")

            # Configure and install the library
            os.chdir(os.path.expanduser("~/libsodium-0.2/"))
            run("./configure --disable-debug --disable-dependency-tracking")
            run("make")
            run("make install")
        finally:
            os.chdir(curdir)

    def _install_nacl():
        raise NotImplementedError

    libraries = {
        "libsodium": _install_libsodium,
        "nacl": _install_nacl,
    }

    # Install the library
    libraries[library]()


@task
def install(dev=False):
    if dev:
        # Install once to get the tests extra<commit_msg>Run make install with sudo<commit_after>import hashlib
import os
import urllib2

from invoke import task, run


def download(url, hash, path):
    resp = urllib2.urlopen(url)
    content = resp.read()
    content_hash = hashlib.sha256(content).hexdigest()
    assert hash == content_hash

    with open(path, "wb") as fp:
        fp.write(content)


@task(aliases=["install-nacl"])
def install_nacl(library):
    def _install_libsodium():
        tarball_path = os.path.expanduser("~/libsodium-0.2.tar.gz")

        # Download libsodium and verify it's hash
        download(
            "http://download.dnscrypt.org/libsodium/releases/libsodium-0.2.tar.gz",
            "e99a6b69adc080a5acf6b8a49fdc74b61d6f3579b590e85c93446a8325dde100",
            tarball_path,
        )

        curdir = os.getcwd()
        try:
            os.chdir(os.path.expanduser("~/"))

            # Unpack the tarball
            run("tar xf libsodium-0.2.tar.gz")

            # Configure and install the library
            os.chdir(os.path.expanduser("~/libsodium-0.2/"))
            run("./configure --disable-debug --disable-dependency-tracking")
            run("make")
            run("sudo make install")
        finally:
            os.chdir(curdir)

    def _install_nacl():
        raise NotImplementedError

    libraries = {
        "libsodium": _install_libsodium,
        "nacl": _install_nacl,
    }

    # Install the library
    libraries[library]()


@task
def install(dev=False):
    if dev:
        # Install once to get the tests extra
{'fraction_non_alphanumeric': 0.11568627450980393, 'fraction_numerical': 0.03398692810457516, 'mean_word_length': 2.2843347639484977, 'pattern_counts': {'":': 4, '<': 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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4272263', 'n_tokens_mistral': 1096, 'n_tokens_neox': 987, 'n_words': 196}