<commit_before>import json
import os
import platform
import requests
import sys

class NotFound(Exception):
    pass

def get_url(url, token, ua):
    if token != None:
        return requests.get(url, auth=token, headers={'User-Agent':ua})
    else:
        return requests.get(url)


class Wrapper:

    def __init__(self, user_agent="Wrapper"):
        self.token = None
        self.URL = "http://localhost:5000/"
        self.user_agent = user_agent

    def me(self):
        r = get_url(self.URL+"api/v1/me", self.token, self.user_agent)
        self.raw = json.loads(r.text)
        self.posts = self.raw["posts"]

    def get_user(self, user):
        r = get_url(self.URL+"api/v1/posts/%s" % user, self.token, self.user_agent)
        if r.status_code == 200:
            self.raw = json.loads(r.text)
            self.posts = self.raw["posts"]
        elif r.status_code == 404:
            raise NotFound<commit_msg>api /me now actually works also some internal changes<commit_after>import json
import os
import platform
import requests
import sys

class NotFound(Exception):
    pass

class NotAllowed(Exception):
    pass




class Wrapper:

    def __init__(self, user_agent="Wrapper"):
        self.token = None
        self.URL = "http://localhost:5000/"
        self.user_agent = user_agent

    def get_url(self, url):
        if self.token != None:
            return requests.get(url, headers={'User-Agent':self.user_agent, "Authorization":self.token})
        else:
            return requests.get(url, headers={'User-Agent':self.user_agent})

    def me(self):
        if self.token == None:
            raise NotAllowed
        r = self.get_url(self.URL+"api/v1/me")
        self.raw = json.loads(r.text)
        # self.posts = self.raw["posts"]

    def get_posts(self, user=None):
        if user == None:
            r = self.get_url(self.URL+"api/v1/posts")
        else:
            r = self.get_url(self.URL+"api/v1/posts/%s" % user)

        if r.status_code == 200:
            self.raw = json.loads(r.text)
            self.posts = self.raw["posts"]
            return self.raw
        elif r.status_code == 404:
            raise NotFound
{'fraction_non_alphanumeric': 0.1270718232044199, 'fraction_numerical': 0.01151012891344383, 'mean_word_length': 2.287443267776097, 'pattern_counts': {'":': 1, '<': 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': '1241963', 'n_tokens_mistral': 706, 'n_tokens_neox': 687, 'n_words': 155}