<commit_before>#
# forensics/__init__.py
#

import os
import logging
from .walker_utils import WalkerUtilities


def setupLogger(fullpath=None, level=logging.INFO):
    FORMAT = ("%(asctime)s %(levelname)s %(module)s %(funcName)s "
              "[line:%(lineno)d] %(message)s")
    logging.basicConfig(filename=fullpath, format=FORMAT, level=level)
    return logging.getLogger()


def validatePath(path, file=False, csv=False, dir=False):
    result = False

    if file and os.path.isfile(path):
        if os.access(path, os.R_OK):
            result = True
        else:
            logging.getLogger().critical("File '%s' is not readable.", path)
    elif csv:
        head, tail = os.path.split(path)
        root, ext = os.path.splitext(tail)
        head = head == u'' and u'.' or head
        #print head, tail, ext

        if os.path.isdir(head) and ext.lower() == u'.csv':
            result = True
    elif dir and os.path.isdir(path):<commit_msg>Updated the code to work on Python 2.7 and 3.4.<commit_after>#
# forensics/__init__.py
#

import os
import logging
from .walker_utils import WalkerUtilities


def setupLogger(fullpath=None, level=logging.INFO):
    FORMAT = ("%(asctime)s %(levelname)s %(module)s %(funcName)s "
              "[line:%(lineno)d] %(message)s")
    logging.basicConfig(filename=fullpath, format=FORMAT, level=level)
    return logging.getLogger()


def validatePath(path, file=False, csv=False, dir=False):
    result = False

    if file and os.path.isfile(path):
        if os.access(path, os.R_OK):
            result = True
        else:
            logging.getLogger().critical("File '%s' is not readable.", path)
    elif csv:
        head, tail = os.path.split(path)
        root, ext = os.path.splitext(tail)
        head = head == '' and '.' or head
        #print head, tail, ext

        if os.path.isdir(head) and ext.lower() == '.csv':
            result = True
    elif dir and os.path.isdir(path):
{'fraction_non_alphanumeric': 0.13876088069636458, 'fraction_numerical': 0.002048131080389145, 'mean_word_length': 2.7504798464491365, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '473261', 'n_tokens_mistral': 653, 'n_tokens_neox': 630, 'n_words': 162}