<commit_before># Author: <NAME> <<EMAIL>>
# License: BSD Style.

import os
import os.path as op

def data_path(path='.'):
    """Get path to local copy of Sample dataset

    Parameters
    ----------
    dir : string
        Location of where to look for the sample dataset.
        If not set. The data will be automatically downloaded in
        the local folder.
    """
    archive_name = "MNE-sample-data-processed.tar.gz"
    url = "ftp://surfer.nmr.mgh.harvard.edu/pub/data/" + archive_name
    folder_name = "MNE-sample-data"

    martinos_path = '/homes/6/gramfort/cluster/work/data/MNE-sample-data-processed.tar.gz'
    neurospin_path = '/neurospin/tmp/gramfort/MNE-sample-data-processed.tar.gz'

    if not os.path.exists(op.join(path, folder_name)):
        if os.path.exists(martinos_path):
            archive_name = martinos_path
        elif os.path.exists(neurospin_path):
            archive_name = neurospin_path
        elif not os.path.exists(archive_name):
            import urllib
            print "Downloading data, please Wait (600 MB)..."
            print url
            opener = urllib.urlopen(url)
            open(archive_name, 'wb').write(opener.read())
            print

        import tarfile
        print "Decompressiong the archive: " + archive_name
        tarfile.open(archive_name, "r:gz").extractall(path=path)
        print

    path = op.join(path, folder_name)
    return path<commit_msg>ENH: warning if sample dataset old<commit_after># Author: <NAME> <<EMAIL>>
# License: BSD Style.


def _sample_version(path):
    """Get the version of the Sample dataset"""
    import os.path as op
    ver_fname = op.join(path, 'version.txt')
    if op.exists(ver_fname):
        fid = open(ver_fname, 'r')
        version = fid.readline().strip()  # version is on first line
        fid.close()
    else:
        # Sample dataset versioning was introduced after 0.3
        version = '0.3'

    return version


def data_path(path='.', force_update=False):
    """Get path to local copy of Sample dataset

    Parameters
    ----------
    dir : string
        Location of where to look for the sample dataset.
        If not set. The data will be automatically downloaded in
        the local folder.
    force_update : bool
        Force update of the sample dataset even if a local copy exists.
    """
    import os.path as op
    from warnings import warn
    from distutils.version import LooseVersion

    from ... import __version__ as mne_version

    archive_name = "MNE-sample-data-processed.tar.gz"
    url = "ftp://surfer.nmr.mgh.harvard.edu/pub/data/" + archive_name
    folder_name = "MNE-sample-data"

    martinos_path = '/homes/6/gramfort/cluster/work/data/' + archive_name
    neurospin_path = '/neurospin/tmp/gramfort/' + archive_name

    if not op.exists(op.join(path, folder_name)) or force_update:
        if op.exists(martinos_path):
            archive_name = martinos_path
        elif op.exists(neurospin_path):
            archive_name = neurospin_path
        elif not op.exists(archive_name):
            import urllib
            print "Downloading data, please Wait (600 MB)..."
            print url
            opener = urllib.urlopen(url)
            open(archive_name, 'wb').write(opener.read())
            print

        import tarfile
        print "Decompressiong the archive: " + archive_name
        tarfile.open(archive_name, "r:gz").extractall(path=path)
        print

    path = op.join(path, folder_name)

    # compare the version of the Sample dataset and mne
    sample_version = _sample_version(path)
    if LooseVersion(sample_version) < LooseVersion(mne_version):
        warn('Sample dataset (version %s) is older than mne-python '
             '(version %s). If the examples fail, you may need to update '
             'the sample dataset by using force_update=True' % (sample_version,
             mne_version))

    return path

{'fraction_non_alphanumeric': 0.10321100917431193, 'fraction_numerical': 0.0030581039755351682, 'mean_word_length': 2.4189895470383274, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7565694', 'n_tokens_mistral': 1189, 'n_tokens_neox': 1162, 'n_words': 326}