<commit_before>

def load_state_files(state):


    # check if we're loading from git first

    # check if the directory is readable

    # check if the write out directory is writeable
    pass
<commit_msg>Start fleshing out load.py<commit_after>
import logging

from os import path
from os import access
from os import W_OK
from os import getcwd

from git import Repo


def load_state_files(state):

    print state.file_location
    # check if we're loading from git first
    if _is_git_file_loc(state.file_location):

        try:
            _load_git_files(state)
        except:
            logging.info('Failed to load Git')

    _set_state_file_path(state)


def _set_state_file_path(state):

    if _is_git_file_loc(state.file_location):
        state.file_path = path.join(getcwd(), state.name)
    else:
        state.file_path = state.file_location

    # check if the directory is readable
    if not path.isdir(state.file_path):
        raise Exception("Path %s is not a directory" % state.file_path)

    # check if the write out directory is writeable
    if not access(state.file_path, W_OK):
        raise Exception("tailorscad does not have write permissions")


# TODO: This needs to be more robust
def _is_git_file_loc(file_location):

    if 'git' in file_location:
        return True


def _load_git_files(state):
    Repo(state.file_location)

{'fraction_non_alphanumeric': 0.06710430342815463, 'fraction_numerical': 0.0, 'mean_word_length': 3.182926829268293, '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': '5294600', 'n_tokens_mistral': 437, 'n_tokens_neox': 416, 'n_words': 136}