<commit_before>import dbus
from daemon.tracking import JobStuct


__all__ = ['connect']


def connect():
    bus = dbus.SessionBus()
    obj = bus.get_object('ua.douhack.marvin', '/ua/douhack/marvin')
    client = dbus.Interface(obj, 'ua.douhack.marvin')
    return client


def job_struct_from_tuple(data):
    return JobStuct(
        id=data[0],
        path=data[1],
        total=data[2],
        sent=data[3],
        status=data[4]
    )<commit_msg>Now client convert response to namedtuple<commit_after>import dbus
from daemon.tracking import JobStuct


__all__ = ['connect']


def connect():
    return Client()


def struct(func):
    func_name = func.__name__

    def inner(self, *args, **kwargs):
        return to_struct(getattr(self.server, func_name)(*args, **kwargs))
    return inner


def structs(func):
    func_name = func.__name__

    def inner(self, *args, **kwargs):
        return map(to_struct, getattr(self.server, func_name)(*args, **kwargs))
    return inner


class Client(object):
    def __init__(self):
        bus = dbus.SessionBus()
        obj = bus.get_object('ua.douhack.marvin', '/ua/douhack/marvin')
        self.server = dbus.Interface(obj, 'ua.douhack.marvin')

    def __getattr__(self, item):
        getattr(self.server, item)

    @struct
    def info(self):
        pass

    @structs
    def list_sending(self):
        pass

    @structs
    def hist(self):
        pass


def to_struct(data):
    return JobStuct(
        id=data[0],
        path=data[1],
        total=data[2],
        sent=data[3],
        status=data[4]
    )
{'fraction_non_alphanumeric': 0.13037974683544304, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 2.7642857142857142, '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': '1305783', 'n_tokens_mistral': 556, 'n_tokens_neox': 531, 'n_words': 113}