<commit_before>from nbt import *
import json
import urllib2
from directories import userCachePath
import os
import json
import time

def getPlayerNameFromUUID(uuid):
    t = time.time()
    nuuid = uuid.replace("-", "")
    try:
        if not os.path.exists(userCachePath):
            usercache = {}
            print "Usercache doesn't exist, will not cache"
        else:
            f = open(userCachePath,"r+")
            usercache = json.loads(f.read())

        refreshUUID = True
        if os.path.exists(userCachePath) and uuid in usercache and "timestamp" in usercache[uuid] and t-usercache[uuid]["timestamp"] < 21600:
            refreshUUID = False

        if refreshUUID:
            try:
                print "Loading {} from network".format(uuid)
                playerJSONResponse = urllib2.urlopen("https://api.mojang.com/user/profiles/{}/names".format(nuuid)).read()
                playerJSON = json.loads(playerJSONResponse)
                username = playerJSON[0]
                usercache[uuid] = {"username":username,"timestamp":t}
            except:
                print "A network error occured"
                return uuid

        if os.path.exists(userCachePath):
            f.seek(0)
            f.write(json.dumps(usercache))
            f.close()
        return usercache[uuid]["username"]
    except:
        print "Unable to r/w user cache file"
        return uuid<commit_msg>Fixed an issue with shutil not being defined<commit_after>from nbt import *
import json
import urllib2
from directories import userCachePath
import os
import json
import time

def getPlayerNameFromUUID(uuid):
    try:
        t = time.time()
    except:
        t = 0
    nuuid = uuid.replace("-", "")
    try:
        if not os.path.exists(userCachePath):
            usercache = {}
            print "{} doesn't exist, will not cache".format(userCachePath)
        else:
            try:
                f = open(userCachePath,"r+")
                usercache = json.loads(f.read())
            except:
                print "Error loading {} from disk".format(userCachePath)
                usercache = {}

        try:
            if os.path.exists(userCachePath) and uuid in usercache and "timestamp" in usercache[uuid] and t-usercache[uuid]["timestamp"] < 21600:
                refreshUUID = False
            else:
                refreshUUID = False
        except:
            refreshUUID = True

        if refreshUUID:
            try:
                print "Loading {} from network".format(uuid)
                playerJSONResponse = urllib2.urlopen("https://api.mojang.com/user/profiles/{}/names".format(nuuid)).read()
                playerJSON = json.loads(playerJSONResponse)
                username = playerJSON[0]
                usercache[uuid] = {"username":username,"timestamp":t}
            except:
                print "Error loading {} from network".format(uuid)
                return uuid
        try:
            if os.path.exists(userCachePath):
                f.seek(0)
                f.write(json.dumps(usercache))
                f.close()
        except:
            print "Error writing {} to disk".format(userCachePath)
        return usercache[uuid]["username"]
    except:
        print "An error occured getting the username for {}".format(uuid)
        return uuid
{'fraction_non_alphanumeric': 0.10225563909774436, 'fraction_numerical': 0.005714285714285714, 'mean_word_length': 1.8672413793103448, 'pattern_counts': {'":': 4, '<': 5, '<?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': '7028021', 'n_tokens_mistral': 915, 'n_tokens_neox': 913, 'n_words': 225}