Skip to content

Commit 3f9a506

Browse files
committed
Fix relative imports
1 parent e26b45b commit 3f9a506

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

codecs/bits.pyx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
66

77

8-
from ..types import BitString
9-
10-
118
cdef bits_encode(CodecContext settings, WriteBuffer wbuf, obj):
129
cdef:
1310
Py_buffer pybuf
@@ -20,7 +17,7 @@ cdef bits_encode(CodecContext settings, WriteBuffer wbuf, obj):
2017
buf = cpython.PyBytes_AS_STRING(obj)
2118
len = cpython.Py_SIZE(obj)
2219
bitlen = len * 8
23-
elif isinstance(obj, BitString):
20+
elif isinstance(obj, pgproto_types.BitString):
2421
cpython.PyBytes_AsStringAndSize(obj.bytes, &buf, &len)
2522
bitlen = obj.__len__()
2623
else:
@@ -47,4 +44,4 @@ cdef bits_decode(CodecContext settings, FRBuffer *buf):
4744
ssize_t buf_len = buf.len
4845

4946
bytes_ = cpython.PyBytes_FromStringAndSize(frb_read_all(buf), buf_len)
50-
return BitString.frombytes(bytes_, bitlen)
47+
return pgproto_types.BitString.frombytes(bytes_, bitlen)

codecs/geometry.pyx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
66

77

8-
from ..types import Box, Line, LineSegment, Path, Point, Polygon, Circle
9-
10-
118
cdef inline _encode_points(WriteBuffer wbuf, object points):
129
cdef object point
1310

@@ -28,7 +25,7 @@ cdef inline _decode_points(FRBuffer *buf):
2825
for i in range(npts):
2926
x = hton.unpack_double(frb_read(buf, 8))
3027
y = hton.unpack_double(frb_read(buf, 8))
31-
point = Point(x, y)
28+
point = pgproto_types.Point(x, y)
3229
cpython.Py_INCREF(point)
3330
cpython.PyTuple_SET_ITEM(pts, i, point)
3431

@@ -47,7 +44,9 @@ cdef box_decode(CodecContext settings, FRBuffer *buf):
4744
double low_x = hton.unpack_double(frb_read(buf, 8))
4845
double low_y = hton.unpack_double(frb_read(buf, 8))
4946

50-
return Box(Point(high_x, high_y), Point(low_x, low_y))
47+
return pgproto_types.Box(
48+
pgproto_types.Point(high_x, high_y),
49+
pgproto_types.Point(low_x, low_y))
5150

5251

5352
cdef line_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -63,7 +62,7 @@ cdef line_decode(CodecContext settings, FRBuffer *buf):
6362
double B = hton.unpack_double(frb_read(buf, 8))
6463
double C = hton.unpack_double(frb_read(buf, 8))
6564

66-
return Line(A, B, C)
65+
return pgproto_types.Line(A, B, C)
6766

6867

6968
cdef lseg_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -78,7 +77,7 @@ cdef lseg_decode(CodecContext settings, FRBuffer *buf):
7877
double p2_x = hton.unpack_double(frb_read(buf, 8))
7978
double p2_y = hton.unpack_double(frb_read(buf, 8))
8079

81-
return LineSegment((p1_x, p1_y), (p2_x, p2_y))
80+
return pgproto_types.LineSegment((p1_x, p1_y), (p2_x, p2_y))
8281

8382

8483
cdef point_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -92,7 +91,7 @@ cdef point_decode(CodecContext settings, FRBuffer *buf):
9291
double x = hton.unpack_double(frb_read(buf, 8))
9392
double y = hton.unpack_double(frb_read(buf, 8))
9493

95-
return Point(x, y)
94+
return pgproto_types.Point(x, y)
9695

9796

9897
cdef path_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -106,7 +105,7 @@ cdef path_encode(CodecContext settings, WriteBuffer wbuf, obj):
106105
is_closed = 1
107106
elif cpython.PyList_Check(obj):
108107
is_closed = 0
109-
elif isinstance(obj, Path):
108+
elif isinstance(obj, pgproto_types.Path):
110109
is_closed = obj.is_closed
111110

112111
npts = len(obj)
@@ -125,7 +124,7 @@ cdef path_decode(CodecContext settings, FRBuffer *buf):
125124
cdef:
126125
int8_t is_closed = <int8_t>(frb_read(buf, 1)[0])
127126

128-
return Path(*_decode_points(buf), is_closed=is_closed == 1)
127+
return pgproto_types.Path(*_decode_points(buf), is_closed=is_closed == 1)
129128

130129

131130
cdef poly_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -146,7 +145,7 @@ cdef poly_encode(CodecContext settings, WriteBuffer wbuf, obj):
146145

147146

148147
cdef poly_decode(CodecContext settings, FRBuffer *buf):
149-
return Polygon(*_decode_points(buf))
148+
return pgproto_types.Polygon(*_decode_points(buf))
150149

151150

152151
cdef circle_encode(CodecContext settings, WriteBuffer wbuf, obj):
@@ -162,4 +161,4 @@ cdef circle_decode(CodecContext settings, FRBuffer *buf):
162161
double center_y = hton.unpack_double(frb_read(buf, 8))
163162
double radius = hton.unpack_double(frb_read(buf, 8))
164163

165-
return Circle((center_x, center_y), radius)
164+
return pgproto_types.Circle((center_x, center_y), radius)

pgproto.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ from libc.stdint cimport int8_t, uint8_t, int16_t, uint16_t, \
1919
from . cimport hton
2020

2121
from .debug cimport PG_DEBUG
22+
from . import types as pgproto_types
2223

2324

2425
include "./consts.pxi"

0 commit comments

Comments
 (0)