<commit_before>#!/usr/bin/python

import string
import json
import os
import ConfigParser
import transports

cache={}




class xbmcjsonapi:
    def __init__(self):
        pass


# config = ConfigParser.RawConfigParser()
# config.read(os.path.expanduser('~') + '/.xbmcjsonapi')
# username=config.get('http','username')
# password=config.get('http','password')
# port=config.get('http','port')
# json_url=config.get('http','json_url')
# host=config.get('http','host')

config = ConfigParser.RawConfigParser()
config.read(os.path.expanduser('~') + '/.xbmcjsonapi')
port=config.get('tcp','port')
buffer_size=config.get('tcp','buffer_size')
host=config.get('tcp','host')



# transport_instance=transports.HTTPtransport(**{'port': port, 'host': host, 'username': username, 'password': password})
transport_instance=transports.TCPtransport(**{'port': port, 'host': host, 'buffer_size': buffer_size})


def namespaces():
    namespaces=[]
    for method in json.loads(transport_instance.request(transport_instance.json_introspect))['result']['methods']:
        if method.split('.')[0] not in namespaces:
            namespaces.append(method.split('.')[0])
    return namespaces


for namespace in namespaces():
    s = """class %s(xbmcjsonapi):
    \"\"\"XBMC %s namespace. \"\"\"
    pass
    """%(namespace,namespace)
    exec (s)

cache=json.loads(transport_instance.request(transport_instance.json_introspect))['result']['methods']
for namespace in namespaces():
    for key in cache:
        if namespace in key:
            function_name=key.split('.')[1]
            s="""def %s(self, *args, **kwargs):
            \"\"\"
            Description : %s 
            Parameters : %s
            Returns : %s
            \"\"\"
            json_request='{ "jsonrpc": "2.0", "method": "%s.%s"'
            if kwargs=={}:
                json_request=json_request+'}'
            else:
                json_request=json_request+json.dumps(kwargs)+'}'
            return transport_instance.request(json_request)
            """ % (function_name, cache[key]['description'], cache[key]['params'], cache[key]['returns'], namespace, function_name)
            exec(s)<commit_msg>Correction of passing json parameters.<commit_after>#!/usr/bin/python

import string
import json
import os
import ConfigParser
import transports

cache={}




class xbmcjsonapi:
    def __init__(self):
        pass


# config = ConfigParser.RawConfigParser()
# config.read(os.path.expanduser('~') + '/.xbmcjsonapi')
# username=config.get('http','username')
# password=config.get('http','password')
# port=config.get('http','port')
# json_url=config.get('http','json_url')
# host=config.get('http','host')

config = ConfigParser.RawConfigParser()
config.read(os.path.expanduser('~') + '/.xbmcjsonapi')
port=config.get('tcp','port')
buffer_size=config.get('tcp','buffer_size')
host=config.get('tcp','host')



# transport_instance=transports.HTTPtransport(**{'port': port, 'host': host, 'username': username, 'password': password})
transport_instance=transports.TCPtransport(**{'port': port, 'host': host, 'buffer_size': buffer_size})


def namespaces():
    namespaces=[]
    for method in json.loads(transport_instance.request(transport_instance.json_introspect))['result']['methods']:
        if method.split('.')[0] not in namespaces:
            namespaces.append(method.split('.')[0])
    return namespaces


for namespace in namespaces():
    s = """class %s(xbmcjsonapi):
    \"\"\"XBMC %s namespace. \"\"\"
    pass
    """%(namespace,namespace)
    exec (s)

cache=json.loads(transport_instance.request(transport_instance.json_introspect))['result']['methods']
for namespace in namespaces():
    for key in cache:
        if namespace in key:
            function_name=key.split('.')[1]
            s="""def %s(self, *args, **kwargs):
            \"\"\"
            Description : %s 
            Parameters : %s
            Returns : %s
            \"\"\"
            json_request='{ "jsonrpc": "2.0", "method": "%s.%s"'
            if kwargs=={}:
                json_request=json_request+'}'
            else:
                json_request=json_request + ',' + json.dumps(kwargs)[1:-1]+'}'
            return transport_instance.request(json_request)
            """ % (function_name, cache[key]['description'], cache[key]['params'], cache[key]['returns'], namespace, function_name)
            exec(s)
{'fraction_non_alphanumeric': 0.17781328463821044, 'fraction_numerical': 0.0027391006619493265, 'mean_word_length': 3.5503634475597092, 'pattern_counts': {'":': 4, '<': 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': '6689049', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1323, 'n_words': 242}