<commit_before># encoding: utf-8
from __future__ import absolute_import, print_function, division

import os
import subprocess

from pebble_tool.exceptions import ToolError
from pebble_tool.util.versions import version_to_key


def check_npm():
    try:
        npm_version = subprocess.check_output(["npm", "--version"]).strip()
        if version_to_key(npm_version)[0] < 3:
            raise ToolError("We require npm3; you are using version {}.".format(npm_version))
    except subprocess.CalledProcessError:
        raise ToolError(u"You must have npm ≥ 3.0.0 available on your path.")


def invoke_npm(args):
    check_npm()
    subprocess.check_call(["npm"] + args)


def sanity_check():
    if not os.path.exists('node_modules'):
        return
    for d in os.listdir('node_modules'):<commit_msg>Add check for isdir to handle non-directories<commit_after># encoding: utf-8
from __future__ import absolute_import, print_function, division

import os
import subprocess

from pebble_tool.exceptions import ToolError
from pebble_tool.util.versions import version_to_key


def check_npm():
    try:
        npm_version = subprocess.check_output(["npm", "--version"]).strip()
        if version_to_key(npm_version)[0] < 3:
            raise ToolError("We require npm3; you are using version {}.".format(npm_version))
    except subprocess.CalledProcessError:
        raise ToolError(u"You must have npm ≥ 3.0.0 available on your path.")


def invoke_npm(args):
    check_npm()
    subprocess.check_call(["npm"] + args)


def sanity_check():
    if not os.path.exists('node_modules'):
        return
    for d in os.listdir('node_modules'):
        if not os.path.isdir(d):
            continue
{'fraction_non_alphanumeric': 0.10613207547169812, 'fraction_numerical': 0.008254716981132075, 'mean_word_length': 3.713888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7185435', 'n_tokens_mistral': 549, 'n_tokens_neox': 516, 'n_words': 143}