<commit_before>#!/usr/bin/env python
import json
import requests
import sys
import getopt


def _jdefault(obj):
    return obj.__dict__


def load(inputfile, destination):
    json_file = open(inputfile)
    json_data = json.load(json_file)

    for i in json_data:
        data = json.dumps(i, default=_jdefault)
        print('Posting: %s' % data)
        r = requests.post(
            destination,
            data=data,
            headers={'Content-type': 'application/json'})
        print r.status_code

    json_file.close()


def load_singular_objects(inputfile, destination):
    parent_route, dynamic_part = destination.split('{')
    parent_route = parent_route.strip('/')
    id_field, singlular_field = dynamic_part.split('}')
    singlular_field = singlular_field.strip('/')

    json_file = open(inputfile)
    json_data = json.load(json_file)
    objects_count = len(json_data)

    query_string = '?_limit={}'.format(objects_count)
    # query_string = '?_limit={}&_fields={}'.format(objects_count, id_field)<commit_msg>Remove post2api comment<commit_after>#!/usr/bin/env python
import json
import requests
import sys
import getopt


def _jdefault(obj):
    return obj.__dict__


def load(inputfile, destination):
    json_file = open(inputfile)
    json_data = json.load(json_file)

    for i in json_data:
        data = json.dumps(i, default=_jdefault)
        print('Posting: %s' % data)
        r = requests.post(
            destination,
            data=data,
            headers={'Content-type': 'application/json'})
        print r.status_code

    json_file.close()


def load_singular_objects(inputfile, destination):
    parent_route, dynamic_part = destination.split('{')
    parent_route = parent_route.strip('/')
    id_field, singlular_field = dynamic_part.split('}')
    singlular_field = singlular_field.strip('/')

    json_file = open(inputfile)
    json_data = json.load(json_file)
    objects_count = len(json_data)

    query_string = '?_limit={}'.format(objects_count)
{'fraction_non_alphanumeric': 0.11934361014420686, 'fraction_numerical': 0.0004972650422675286, 'mean_word_length': 3.402625820568928, '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': '2203656', 'n_tokens_mistral': 652, 'n_tokens_neox': 636, 'n_words': 126}