Merge pull request #28 from fedotovaleksandr/master
Add compatibility with python 3 - relative imports, fix xrange, fix t…
This commit is contained in:
commit
965b7a994d
@ -1,5 +1,6 @@
|
|||||||
language: python
|
language: python
|
||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
- "3.6"
|
||||||
# command to run tests
|
# command to run tests
|
||||||
script: python test.py
|
script: python test.py
|
||||||
|
7
test.py
7
test.py
@ -5,7 +5,12 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
import codecs
|
import codecs
|
||||||
from mock import patch, Mock, MagicMock
|
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
from mock import patch, Mock, MagicMock
|
||||||
|
else:
|
||||||
|
from unittest.mock import patch, Mock, MagicMock
|
||||||
|
|
||||||
mock_socket = MagicMock(name='zk.socket')
|
mock_socket = MagicMock(name='zk.socket')
|
||||||
sys.modules['zk.socket'] = mock_socket
|
sys.modules['zk.socket'] = mock_socket
|
||||||
from zk import ZK, const
|
from zk import ZK, const
|
||||||
|
12
zk/base.py
12
zk/base.py
@ -5,11 +5,11 @@ from socket import AF_INET, SOCK_DGRAM, SOCK_STREAM, socket, timeout
|
|||||||
from struct import pack, unpack
|
from struct import pack, unpack
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
from zk import const
|
from . import const
|
||||||
from zk.attendance import Attendance
|
from .attendance import Attendance
|
||||||
from zk.exception import ZKErrorConnection, ZKErrorResponse, ZKNetworkError
|
from .exception import ZKErrorConnection, ZKErrorResponse, ZKNetworkError
|
||||||
from zk.user import User
|
from .user import User
|
||||||
from zk.finger import Finger
|
from .finger import Finger
|
||||||
|
|
||||||
|
|
||||||
def safe_cast(val, to_type, default=None):
|
def safe_cast(val, to_type, default=None):
|
||||||
@ -302,7 +302,7 @@ class ZK(object):
|
|||||||
|
|
||||||
def __reverse_hex(self, hex):
|
def __reverse_hex(self, hex):
|
||||||
data = ''
|
data = ''
|
||||||
for i in reversed(xrange(len(hex) / 2)):
|
for i in reversed(range(len(hex) / 2)):
|
||||||
data += hex[i * 2:(i * 2) + 2]
|
data += hex[i * 2:(i * 2) + 2]
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user