# Path: bl/debug.py
# DEBUG = _Debug()


from functools import partial
from twisted.python import log
from bl.debug import DEBUG


class XY(object):

    def __init__(self, receiver, callback=lambda x, y: None, callbacks=None,
                 page=1):
        self.receiver = receiver
        self.callbacks = callbacks
        self.callback = callback
        self.page = page

    def attach(self):
        self._recv_callbacks = []
        if self.callbacks:
            for (idx, cb) in enumerate(self.callbacks):
                node = '/%d/xy%d' % (self.page, idx + 1)
                recvcb = partial(self._callback, cb, node)
                self._recv_callbacks.append((node, recvcb))
                self.receiver.addCallback(node, recvcb)
        else:
            node = '/%d/xy' % self.page
            recvcb = partial(self._callback, self.callback, node)
            self._recv_callbacks.append((node, recvcb))
            self.receiver.addCallback(node, recvcb)
        return self

    def _callback(self, cb, node, message, address):
        (x, y) = message.arguments
        x = float(x)
        y = float(y)

# Path: bl/debug.py
# DEBUG = _Debug()


# Path: bl/osc/touchosc.py
from functools import partial
from twisted.python import log
from bl.debug import DEBUG



class XY(object):

    def __init__(self, receiver, callback=lambda x, y: None, callbacks=None,
                 page=1):
        self.receiver = receiver
        self.callbacks = callbacks
        self.callback = callback
        self.page = page

    def attach(self):
        self._recv_callbacks = []
        if self.callbacks:
            for (idx, cb) in enumerate(self.callbacks):
                node = '/%d/xy%d' % (self.page, idx + 1)
                recvcb = partial(self._callback, cb, node)
                self._recv_callbacks.append((node, recvcb))
                self.receiver.addCallback(node, recvcb)
        else:
            node = '/%d/xy' % self.page
            recvcb = partial(self._callback, self.callback, node)
            self._recv_callbacks.append((node, recvcb))
            self.receiver.addCallback(node, recvcb)
        return self

    def _callback(self, cb, node, message, address):
        (x, y) = message.arguments
        x = float(x)
        y = float(y)

        if DEBUG: