<commit_before># -*- coding: utf-8 -*-

# HifiMedia
# for HIFIakademie.de devices

# Copyright 2009, <NAME> <<EMAIL>>

import simplejson as json
from twisted.web import resource,static

from hifimedia import log

class JsonInterface(resource.Resource,log.Loggable):
    logCategory = 'json'

    def __init__(self, controlpoint):
        self.controlpoint = controlpoint
        self.controlpoint.coherence.add_web_resource('json',
                                        self)
        self.children = {}

    def getChildWithDefault(self, path, request):
        self.warning('getChildWithDefault, %s, %s, %s %s' % (request.method, path, request.uri, request.client))
        if request.method == 'GET':
            if path == 'devices':
                return self.list_devices(request)


    def list_devices(self,request):
        devices = []
        for device in self.controlpoint.get_devices():
            devices.append(device.as_dict())
        return static.Data(json.dumps(devices),'application/json')<commit_msg>importing the log from the proper place<commit_after># -*- coding: utf-8 -*-

# HifiMedia
# for HIFIakademie.de devices

# Copyright 2009, <NAME> <<EMAIL>>

import simplejson as json
from twisted.web import resource,static

from coherence import log

class JsonInterface(resource.Resource,log.Loggable):
    logCategory = 'json'

    def __init__(self, controlpoint):
        self.controlpoint = controlpoint
        self.controlpoint.coherence.add_web_resource('json',
                                        self)
        self.children = {}

    def getChildWithDefault(self, path, request):
        self.warning('getChildWithDefault, %s, %s, %s %s' % (request.method, path, request.uri, request.client))
        if request.method == 'GET':
            if path == 'devices':
                return self.list_devices(request)


    def list_devices(self,request):
        devices = []
        for device in self.controlpoint.get_devices():
            devices.append(device.as_dict())
        return static.Data(json.dumps(devices),'application/json')
{'fraction_non_alphanumeric': 0.11549566891241578, 'fraction_numerical': 0.004812319538017324, 'mean_word_length': 2.7324955116696588, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '608615', 'n_tokens_mistral': 596, 'n_tokens_neox': 573, 'n_words': 137}