<commit_before>#!/usr/bin/python

import json, re
import sys, time
from occi_curl import occi_curl
from occi_libs import *
import my_config

results = []

def DISCOVERY001():
    body, h, http_status, content_type = occi_curl()

    err_msg = []
    check01 = False
    check02a = False<commit_msg>Separated out parsing the body.<commit_after>#!/usr/bin/python

import json, re
import sys, time
from occi_curl import occi_curl
from occi_libs import *
import my_config

results = []

category = []


def get_categories():
    body, h, http_status, content_type = occi_curl()

    for line in body:
        item = {}
        chunks = re.split(';', line)
        if re.match(r'^Category:', chunks[0]):
            value = re.sub(r'^Category:\s+', '', chunks[0])
            item['id'] = value

            # skip the first chunk (category)
            for chunk in chunks[1:]:
                keyvalue = re.split(r'\s*=\s*', chunk, 1)
                print keyvalue
                key = keyvalue[0]
                value = keyvalue[1].strip('"')
                item[key] = value

            category.append(item)

    return [body,  h, http_status, content_type]


def DISCOVERY001():
    body, h, http_status, content_type = get_categories()

    err_msg = []
    check01 = False
    check02a = False
{'fraction_non_alphanumeric': 0.11990776325903152, 'fraction_numerical': 0.015372790161414296, 'mean_word_length': 2.3994778067885116, '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': '4448411', 'n_tokens_mistral': 446, 'n_tokens_neox': 411, 'n_words': 112}