<commit_before># encoding: utf-8

import time
import os

def log(s):
    ''' prints to a log file '''
    message = "%s\t%s" % (time.strftime('%c'), s)
    with open('log.txt', 'a') as out:
        print >> out, message

def get_outdir(out):
    ''' Create a function to add output directory to a given directory
    
    >>> d_func = get_outdir('test')
    >>> print d_func('another_directory')
    test/another_directory
    
     '''
    def s(s):
        # TODO make sure directories exist and if not, make them
        return out + '/' + s.lstrip('/')
    return s

def ohai(s):
    '''
    Status message for when something mediocre happens
    
    Used for general status messages
    
    >>> ohai('I am a test AMA')
     ✪ I am a test AMA
    '''
    log(s)
    print ' ✪ %s' % (s)

def okay(s):
    '''
    Status message for when something good happens
    
    >>> okay('I did something cool')
     ✓ I did something cool
    '''
    log(s)
    print ' ✓ %s' % (s)

def ohno(s):
    '''
    Status message for when something bad happens
    Terminates the program with an exit status of 1
    
    # didnt write test for this because it always fails
    
    '''
    log(s)
    print '\n ✖ %s' % (s)
    quit(1)

def run(cmd, generates=False, force=False, silent=False):
    ''' Runs a system command unless output exists unless forced.
    Prints a message when it's done'
    
    # run a command
    >>> run('ls > /dev/null')
     ✓ ls > /dev/null
    
    # run a command unless a file already exists
    >>> run('ls helps.py', generates='helps.py')
     ✓ skipping
    
    # run a command and force it
    # (same as taking out the generates)<commit_msg>ohno now raises an exception instead of quitting<commit_after># encoding: utf-8

import time
import os

def log(s):
    ''' prints to a log file '''
    message = "%s\t%s" % (time.strftime('%c'), s)
    with open('log.txt', 'a') as out:
        print >> out, message

def get_outdir(out):
    ''' Create a function to add output directory to a given directory
    
    >>> d_func = get_outdir('test')
    >>> print d_func('another_directory')
    test/another_directory
    
     '''
    def s(s):
        # TODO make sure directories exist and if not, make them
        return out + '/' + s.lstrip('/')
    return s

def ohai(s):
    '''
    Status message for when something mediocre happens
    
    Used for general status messages
    
    >>> ohai('I am a test AMA')
     ✪ I am a test AMA
    '''
    log(s)
    print ' ✪ %s' % (s)

def okay(s):
    '''
    Status message for when something good happens
    
    >>> okay('I did something cool')
     ✓ I did something cool
    '''
    log(s)
    print ' ✓ %s' % (s)

def ohno(s):
    '''
    Status message for when something bad happens
    
    Also, raises an Exception
    
    >>> try:
    ...     ohno('fail')
    ... except:
    ...     pass
     ✖ fail
    
    '''
    log(s)
    print ' ✖ %s' % (s)
    
    raise Exception, s

def run(cmd, generates=False, force=False, silent=False, sgi=False):
    ''' Runs a system command unless output exists unless forced.
    Prints a message when it's done'
    
    # run a command
    >>> run('ls > /dev/null')
     ✓ ls > /dev/null
    
    # run a command unless a file already exists
    >>> run('ls helps.py', generates='helps.py')
     ✓ skipping
    
    # run a command and force it
    # (same as taking out the generates)
{'fraction_non_alphanumeric': 0.12675644028103045, 'fraction_numerical': 0.00117096018735363, 'mean_word_length': 2.1904761904761907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 50, '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': '1308404', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1095, 'n_words': 402}