<commit_before># -*- encoding: utf-8 -*-
# [call this script from a3 root with ./bin/python3.4 as interpreter.]
# FIXME: Doesn't work as requests is missing. Use a Python with requests
# installed.

import os
import json
import requests
from random import choice
from random import randint

# FIXME: root_uri must be constructed from etc/*.ini, not hard-coded here!
root_uri = 'http://localhost:6542'
verbose = True

ALPHABET = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"
WHITESPACE = " "
def get_random_string(n=10, whitespace=False):
    alphabet = ALPHABET + WHITESPACE if whitespace else ALPHABET
    return "".join(choice(alphabet) for i in range(n));

# for more javascript-ish json representation:
null = None
true = True
false = False

def login(name="god", password="password"):
    """login user and return user token """

    uri = root_uri + "/login_username"
    headers = {
        "Content-Type": "application/json;charset=UTF-8",
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip,deflate",
        "Connection": "keep-alive",
        "Accept-Language": "en-US,en;q=0.8",
        "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36",
        "Content-Length": "36"
    }
    body = json.dumps({
        "name": name,
        "password": password
    })
    response = requests.post(uri, headers=headers, data=body)
    if verbose:
        print('\n')
        print(uri)
        print(headers)
        print(body)
        print(response)
        print(response.text)
    assert response.status_code == 200

    payload = json.loads(response.content)
    assert payload["status"] == "success"

    return payload["user_token"]

def _create_proposal():
    name = get_random_string()

    location_is_specific = true if randint(0,1) else false
    location_is_linked_to_ruhr = true if randint(0,1) else false
    location_is_online = true if randint(0,1) else false
    location_specific_1 = None<commit_msg>fixing issue that json expects argument of type str not of type byte<commit_after># -*- encoding: utf-8 -*-
# [call this script from a3 root with ./bin/python3.4 as interpreter.]
# FIXME: Doesn't work as requests is missing. Use a Python with requests
# installed.

import os
import json
import requests
from random import choice
from random import randint

# FIXME: root_uri must be constructed from etc/*.ini, not hard-coded here!
root_uri = 'http://localhost:6542'
verbose = True

ALPHABET = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"
WHITESPACE = " "
def get_random_string(n=10, whitespace=False):
    alphabet = ALPHABET + WHITESPACE if whitespace else ALPHABET
    return "".join(choice(alphabet) for i in range(n));

# for more javascript-ish json representation:
null = None
true = True
false = False

def login(name="god", password="password"):
    """login user and return user token """

    uri = root_uri + "/login_username"
    headers = {
        "Content-Type": "application/json;charset=UTF-8",
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip,deflate",
        "Connection": "keep-alive",
        "Accept-Language": "en-US,en;q=0.8",
        "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36",
        "Content-Length": "36"
    }
    body = json.dumps({
        "name": name,
        "password": password
    })
    response = requests.post(uri, headers=headers, data=body)
    if verbose:
        print('\n')
        print(uri)
        print(headers)
        print(body)
        print(response)
        print(response.text)
    assert response.status_code == 200

    payload = json.loads(response.text)
    assert payload["status"] == "success"

    return payload["user_token"]

def _create_proposal():
    name = get_random_string()

    location_is_specific = true if randint(0,1) else false
    location_is_linked_to_ruhr = true if randint(0,1) else false
    location_is_online = true if randint(0,1) else false
    location_specific_1 = None
{'fraction_non_alphanumeric': 0.12198649951783992, 'fraction_numerical': 0.03037608486017358, 'mean_word_length': 3.4091392136025505, 'pattern_counts': {'":': 18, '<': 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': '5009328', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1381, 'n_words': 357}