From b77831f225d08129c1ff55c59d6a79cc1e514a8c Mon Sep 17 00:00:00 2001 From: Andrey Pohilko Date: Sat, 23 Sep 2017 10:45:05 +0300 Subject: [PATCH] Get rid of six as dependency --- pylgbst/comms.py | 20 ++------------------ pylgbst/constants.py | 20 ++++++++++++++++++++ pylgbst/movehub.py | 33 ++++++++++++++++++++++++++------- pylgbst/peripherals.py | 4 ---- setup.py | 2 +- 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/pylgbst/comms.py b/pylgbst/comms.py index b487be6..0a26241 100644 --- a/pylgbst/comms.py +++ b/pylgbst/comms.py @@ -5,31 +5,16 @@ import binascii import json import logging import socket -import sys import traceback from abc import abstractmethod from binascii import unhexlify +from gattlib import DiscoveryService, GATTRequester from threading import Thread -from gattlib import DiscoveryService, GATTRequester -from six.moves import queue - -from pylgbst.constants import MSG_DEVICE_SHUTDOWN +from pylgbst.constants import MSG_DEVICE_SHUTDOWN, queue, str2hex log = logging.getLogger('comms') - -def str2hex(data): # TODO: eliminate it - return binascii.hexlify(data).decode("utf8") - - -if sys.version_info[0] == 2: - def get_byte(seq, index): - return ord(seq[index]) -else: - def get_byte(seq, index): - return seq[index] - LEGO_MOVE_HUB = "LEGO Move Hub" @@ -44,7 +29,6 @@ class Requester(GATTRequester): super(Requester, self).__init__(p_object, *args, **kwargs) self.notification_sink = None - # noinspection PyUnresolvedReferences self._notify_queue = queue.Queue() # this queue is to minimize time spent in gattlib C code thr = Thread(target=self._dispatch_notifications) thr.setDaemon(True) diff --git a/pylgbst/constants.py b/pylgbst/constants.py index 4742856..0ba66c3 100644 --- a/pylgbst/constants.py +++ b/pylgbst/constants.py @@ -1,3 +1,23 @@ +import binascii +import struct +import sys + +if sys.version_info[0] == 2: + import Queue as queue +else: + import queue as queue + +queue = queue # just to use it + + +def str2hex(data): # TODO: eliminate it + return binascii.hexlify(data).decode("utf8") + + +def get_byte(seq, index): + return struct.unpack("