<commit_before>import os
import sys


THIS_SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))

fuzzManagerPath = os.path.abspath(os.path.join(THIS_SCRIPT_DIRECTORY, os.pardir, os.pardir, 'FuzzManager'))
if not os.path.exists(fuzzManagerPath):
    print "Please check out Lithium and FuzzManager side-by-side with funfuzz. Links in https://github.com/MozillaSecurity/funfuzz/#setup"
    sys.exit(2)
sys.path.append(fuzzManagerPath)
from Collector.Collector import Collector


def createCollector(tool):
    assert tool == "DOMFuzz" or tool == "jsfunfuzz"
    collector = Collector(tool=tool)
    return collector


def printCrashInfo(crashInfo):
    if crashInfo.createShortSignature() != "No crash detected":
        print
        print "crashInfo:"
        print "  Short Signature: " + crashInfo.createShortSignature()
        print "  Class name: " + crashInfo.__class__.__name__   # "NoCrashInfo", etc
        print "  Stack trace: " + repr(crashInfo.backtrace)
        print


def printMatchingSignature(match):
    print "Matches signature in FuzzManager:"
    print "  Signature description: " + match[1].get('shortDescription')
    print "  Signature file: " + match[0]
    print<commit_msg>Instantiate sigCacheDir on Collector object creation by jsInteresting as well.<commit_after>import os
import sys


THIS_SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))

fuzzManagerPath = os.path.abspath(os.path.join(THIS_SCRIPT_DIRECTORY, os.pardir, os.pardir, 'FuzzManager'))
if not os.path.exists(fuzzManagerPath):
    print "Please check out Lithium and FuzzManager side-by-side with funfuzz. Links in https://github.com/MozillaSecurity/funfuzz/#setup"
    sys.exit(2)
sys.path.append(fuzzManagerPath)
from Collector.Collector import Collector


def createCollector(tool):
    assert tool == "DOMFuzz" or tool == "jsfunfuzz"
    sigCacheDir = None
    cacheDir = os.path.normpath(os.path.expanduser(os.path.join("~", "sigcache")))
    if os.path.isdir(cacheDir):
        sCacheDir = cacheDir
    # Define sigCacheDir on instantiation else jsInteresting when run alone will complain
    collector = Collector(sigCacheDir=sCacheDir, tool=tool)
    return collector


def printCrashInfo(crashInfo):
    if crashInfo.createShortSignature() != "No crash detected":
        print
        print "crashInfo:"
        print "  Short Signature: " + crashInfo.createShortSignature()
        print "  Class name: " + crashInfo.__class__.__name__   # "NoCrashInfo", etc
        print "  Stack trace: " + repr(crashInfo.backtrace)
        print


def printMatchingSignature(match):
    print "Matches signature in FuzzManager:"
    print "  Signature description: " + match[1].get('shortDescription')
    print "  Signature file: " + match[0]
    print
{'fraction_non_alphanumeric': 0.10488245931283906, 'fraction_numerical': 0.00216998191681736, 'mean_word_length': 4.010869565217392, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2608577', 'n_tokens_mistral': 894, 'n_tokens_neox': 857, 'n_words': 201}