<commit_before>#!/usr/bin/env python3
# Common tools:
#	pip/pip3 : install packages
#	pep8/pylint/pychecker : verify syntax
#	unittest package for xUnit.
""" This is a simple script to recompile ycm everytime it gets updated. """

# Imports
import os
import shutil
import subprocess
import urllib.request
import tarfile

# Data
CLANG_SITE = 'http://llvm.org/releases/3.4/'
CLANG_FILE = 'clang+llvm-3.4-x86_64-linux-gnu-ubuntu-13.10.tar.xz'
CLANG_URL = '{}{}'.format(CLANG_SITE, CLANG_FILE)
CLANG_DIR = 'clang'
B_DIR = 'build'

# Classes

# Functions


def check_clang():
    """ Check if we have clang, else retrieve it. """
    ext_index = CLANG_FILE.rindex('.tar')
    file_no_ext = CLANG_FILE[0:ext_index]
    list_dir = os.listdir()

    # Protection if clang dir exists.
    if CLANG_DIR in list_dir:
        return

    if CLANG_FILE not in list_dir:
        print('Please wait, downloading clang.')
        urllib.request.urlretrieve(CLANG_URL, CLANG_FILE)
        print('Finished download.')

    if file_no_ext in list_dir:
        shutil.rmtree(file_no_ext)

    tar_file = tarfile.open(CLANG_FILE, 'r')
    tar_file.extractall()
    os.remove(CLANG_FILE)
    os.rename(file_no_ext, CLANG_DIR)

# Main
if __name__ == '__main__':
    # Protection in case build exists prior.
    if B_DIR in os.listdir():
        shutil.rmtree(B_DIR)

    check_clang()

    os.mkdir(B_DIR)
    os.chdir(B_DIR)

    subprocess.call(['cmake', '-GUnix Makefiles',
                     '-DPATH_TO_LLVM_ROOT=../{}'.format(CLANG_DIR), '.',
                     '~/.vim/bundle/YouCompleteMe/cpp'])
    subprocess.call(['make', '-j8', 'ycm_support_libs'])

    os.chdir('..')
    shutil.rmtree(B_DIR)
    shutil.rmtree(CLANG_DIR)<commit_msg>Tidied it up.<commit_after>#!/usr/bin/env python3
# Common tools:
#	pip/pip3 : install packages
#	pep8/pylint/pychecker : verify syntax
#	unittest package for xUnit.
""" This is a simple script to recompile ycm everytime it gets updated. """

# Imports
import os
import shutil
import subprocess
import urllib.request
import tarfile

# Data
CLANG_SITE = 'http://llvm.org/releases/3.4/'
CLANG_FILE = 'clang+llvm-3.4-x86_64-linux-gnu-ubuntu-13.10.tar.xz'
CLANG_URL = '{}{}'.format(CLANG_SITE, CLANG_FILE)
CLANG_DIR = 'clang'
B_DIR = 'build'

# Classes

# Functions


def check_clang():
    """ Check if we have clang, else retrieve it. """
    ext_index = CLANG_FILE.rindex('.tar')
    extracted_dir = CLANG_FILE[0:ext_index]
    list_dir = os.listdir()

    # Protection if clang dir exists.
    if CLANG_DIR in list_dir:
        return

    if CLANG_FILE not in list_dir:
        print('Please wait, downloading clang.')
        urllib.request.urlretrieve(CLANG_URL, CLANG_FILE)
        print('Finished download.')

    if extracted_dir in list_dir:
        shutil.rmtree(extracted_dir)

    tar_file = tarfile.open(CLANG_FILE, 'r')
    tar_file.extractall()
    os.remove(CLANG_FILE)
    os.rename(extracted_dir, CLANG_DIR)

# Main
if __name__ == '__main__':
    check_clang()

    # Protection in case build exists prior.
    if B_DIR in os.listdir():
        shutil.rmtree(B_DIR)

    os.mkdir(B_DIR)
    os.chdir(B_DIR)

    subprocess.call(['cmake', '-GUnix Makefiles',
                     '-DPATH_TO_LLVM_ROOT=../{}'.format(CLANG_DIR), '.',
                     '~/.vim/bundle/YouCompleteMe/cpp'])
    subprocess.call(['make', '-j8', 'ycm_support_libs'])

    os.chdir('..')
    shutil.rmtree(B_DIR)
    shutil.rmtree(CLANG_DIR)
{'fraction_non_alphanumeric': 0.1315028901734104, 'fraction_numerical': 0.009826589595375723, 'mean_word_length': 3.1300715990453463, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2829001', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1270, 'n_words': 263}