Skip to content

Commit a968ff8

Browse files
committed
Moved hex2 to compat
1 parent f08ec3e commit a968ff8

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

neo4j/compat.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,24 @@
3434
except NameError:
3535
integer = int
3636
string = str
37+
38+
def hex2(x):
39+
if x < 0x10:
40+
return "0" + hex(x)[2:].upper()
41+
else:
42+
return hex(x)[2:].upper()
43+
3744
else:
3845
integer = (int, long)
3946
string = (str, unicode)
4047

48+
def hex2(x):
49+
x = ord(x)
50+
if x < 0x10:
51+
return "0" + hex(x)[2:].upper()
52+
else:
53+
return hex(x)[2:].upper()
54+
4155

4256
try:
4357
from multiprocessing import Array, Process

neo4j/connection.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020

2121
from __future__ import division
2222

23-
from collections import deque, namedtuple
23+
from collections import deque
2424
from io import BytesIO
2525
import logging
2626
from os import environ
2727
from select import select
2828
from socket import create_connection, SHUT_RDWR
2929
from struct import pack as struct_pack, unpack as struct_unpack, unpack_from as struct_unpack_from
3030

31-
from .compat import perf_counter, secure_socket
31+
from .compat import hex2, secure_socket
3232
from .exceptions import ProtocolError
33-
from .packstream import Packer, Unpacker, Structure
33+
from .packstream import Packer, Unpacker
3434

3535

3636
DEFAULT_PORT = 7687
@@ -70,13 +70,6 @@
7070
log_error = log.error
7171

7272

73-
def hex2(x):
74-
if x < 0x10:
75-
return "0" + hex(x)[2:].upper()
76-
else:
77-
return hex(x)[2:].upper()
78-
79-
8073
class ChunkChannel(object):
8174
""" Reader/writer for chunked data.
8275

0 commit comments

Comments
 (0)