<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from echonetlite import interfaces
from echonetlite.protocol import *

class Node(object):
    def __init__(self, node_id, devices):
        # _node_id: a layer 3 address string
        self._node_id = node_id
        # _devices: a dict with key as str(eoj), value as Device()
        self._devices = devices

    @property
    def node_id(self):
        return self._node_id

    @property
    def devices(self):
        return self._devices

    def __str__(self):
        s = 'Node ID: {0}'.format(self._node_id)
        for d in self._devices.values():
            s += ', ' + str(d)
        return s

    def get_profile(self):
        profile = None
        for (_, d) in self._devices.items():
            if (d.eoj.clsgrp == CLSGRP_CODE['PROFILE']
                and d.eoj.cls == CLS_CODE['PROFILE']['PROFILE']):
                profile = d
                break
        return profile

    def add_device(self, device):
        self._devices[str(device.eoj)] = device

    def get_device(self, eoj):
        if str(eoj) in self._devices:
            return self._devices[str(eoj)]
        return None

    def remove_device(self, eoj):
        if str(eoj) in self._devices:
            del self._devices[str(eoj)]


class Device(object):
    def __init__(self, eoj=None):
        self._eoj = eoj
        self._properties = {}
        self._listeners = {}

    @property
    def eoj(self):
        return self._eoj

    @property
    def properties(self):
        return self._properties

    @property
    def listeners(self):
        return self._listeners

    def __str__(self):
        s = 'EOJ: {0}'.format(str(self._eoj))
        for epc, edt in self._properties.items():
            s += ', EPC: {0:#04x}, EDT:'.format(epc)
            for dt in edt:
                s += ' {0:02x}'.format(dt)
        return s

    def add_listener(self, epc, func):
        key = self._eoj.clsgrp << 16 | self._eoj.cls << 8 | epc
        self._listeners[key] = func

    def remove_listener(self, epc):
        key = self._eoj.clsgrp << 16 | self._eoj.cls << 8 | epc
        del self._listeners[key]


class LocalDevice(Device):
    def __init__(self, eoj=None):
        super(LocalDevice, self).__init__(eoj)
        self._status_change_property_map = []
        self._set_property_map = []
        self._get_property_map = []

    def _add_property(self, epc, edt):
        self._properties[epc] = edt

    def _get_property(self, epc):
        if epc in self._properties:
            return self._properties[epc]<commit_msg>Added the RemoteDevice class<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from echonetlite import interfaces
from echonetlite.protocol import *

class Node(object):
    def __init__(self, node_id, devices):
        # _node_id: a layer 3 address string
        self._node_id = node_id
        # _devices: a dict with key as str(eoj), value as Device()
        self._devices = devices

    @property
    def node_id(self):
        return self._node_id

    @property
    def devices(self):
        return self._devices

    def __str__(self):
        s = 'Node ID: {0}'.format(self._node_id)
        for d in self._devices.values():
            s += ', ' + str(d)
        return s

    def get_profile(self):
        profile = None
        for (_, d) in self._devices.items():
            if (d.eoj.clsgrp == CLSGRP_CODE['PROFILE']
                and d.eoj.cls == CLS_CODE['PROFILE']['PROFILE']):
                profile = d
                break
        return profile

    def add_device(self, device):
        self._devices[str(device.eoj)] = device

    def get_device(self, eoj):
        if str(eoj) in self._devices:
            return self._devices[str(eoj)]
        return None

    def remove_device(self, eoj):
        if str(eoj) in self._devices:
            del self._devices[str(eoj)]


class Device(object):
    def __init__(self, eoj=None):
        self._eoj = eoj
        self._properties = {}
        self._listeners = {}

    @property
    def eoj(self):
        return self._eoj

    @property
    def properties(self):
        return self._properties

    @property
    def listeners(self):
        return self._listeners

    def __str__(self):
        s = 'EOJ: {0}'.format(str(self._eoj))
        for epc, edt in self._properties.items():
            s += ', EPC: {0:#04x}, EDT:'.format(epc)
            for dt in edt:
                s += ' {0:02x}'.format(dt)
        return s

    def add_listener(self, epc, func):
        key = self._eoj.clsgrp << 16 | self._eoj.cls << 8 | epc
        self._listeners[key] = func

    def remove_listener(self, epc):
        key = self._eoj.clsgrp << 16 | self._eoj.cls << 8 | epc
        del self._listeners[key]


class RemoteDevice(Device):
    pass


class LocalDevice(Device):
    def __init__(self, eoj=None):
        super(LocalDevice, self).__init__(eoj)
        self._status_change_property_map = []
        self._set_property_map = []
        self._get_property_map = []

    def _add_property(self, epc, edt):
        self._properties[epc] = edt

    def _get_property(self, epc):
        if epc in self._properties:
            return self._properties[epc]
{'fraction_non_alphanumeric': 0.1193659281894576, 'fraction_numerical': 0.006111535523300229, 'mean_word_length': 2.078777189888301, 'pattern_counts': {'":': 0, '<': 19, '<?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': '2327690', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1652, 'n_words': 403}