15
15
# This file incorporates work covered by the following copyright:
16
16
# Copyright 2010-2016 RethinkDB, all rights reserved.
17
17
18
- import warnings
18
+ # pylint: disable=redefined-builtin, unused-import
19
+
19
20
from types import SimpleNamespace
21
+ import warnings
20
22
21
23
from rethinkdb import net
22
- # pylint: disable=redefined-builtin
23
24
from rethinkdb .query import (
24
- add , and_ , april , args , asc , august , avg , binary , bit_and , bit_not , bit_or ,
25
- bit_sal , bit_sar , bit_xor , branch , ceil , circle , contains , count , db ,
26
- db_create , db_drop , db_list , december , desc , distance , distinct , div , do ,
27
- epoch_time , eq , error , february , floor , format , friday , ge , geojson , grant ,
28
- group , gt , http , info , intersects , iso8601 , january , json , july , june , le ,
29
- line , literal , lt , make_timezone , map , march , max , maxval , may , min , minval ,
30
- mod , monday , mul , ne , not_ , november , now , object , october , or_ , point ,
31
- polygon , random , range , reduce , round , row , saturday , september , sub , sum ,
32
- sunday , table , table_create , table_drop , table_list , thursday , time , tuesday ,
33
- type_of , union , uuid , wednesday , js
25
+ add ,
26
+ and_ ,
27
+ april ,
28
+ args ,
29
+ asc ,
30
+ august ,
31
+ avg ,
32
+ binary ,
33
+ bit_and ,
34
+ bit_not ,
35
+ bit_or ,
36
+ bit_sal ,
37
+ bit_sar ,
38
+ bit_xor ,
39
+ branch ,
40
+ ceil ,
41
+ circle ,
42
+ contains ,
43
+ count ,
44
+ db ,
45
+ db_create ,
46
+ db_drop ,
47
+ db_list ,
48
+ december ,
49
+ desc ,
50
+ distance ,
51
+ distinct ,
52
+ div ,
53
+ do ,
54
+ epoch_time ,
55
+ eq ,
56
+ error ,
57
+ february ,
58
+ floor ,
59
+ format ,
60
+ friday ,
61
+ ge ,
62
+ geojson ,
63
+ grant ,
64
+ group ,
65
+ gt ,
66
+ http ,
67
+ info ,
68
+ intersects ,
69
+ iso8601 ,
70
+ january ,
71
+ js ,
72
+ json ,
73
+ july ,
74
+ june ,
75
+ le ,
76
+ line ,
77
+ literal ,
78
+ lt ,
79
+ make_timezone ,
80
+ map ,
81
+ march ,
82
+ max ,
83
+ maxval ,
84
+ may ,
85
+ min ,
86
+ minval ,
87
+ mod ,
88
+ monday ,
89
+ mul ,
90
+ ne ,
91
+ not_ ,
92
+ november ,
93
+ now ,
94
+ object ,
95
+ october ,
96
+ or_ ,
97
+ point ,
98
+ polygon ,
99
+ random ,
100
+ range ,
101
+ reduce ,
102
+ round ,
103
+ row ,
104
+ saturday ,
105
+ september ,
106
+ sub ,
107
+ sum ,
108
+ sunday ,
109
+ table ,
110
+ table_create ,
111
+ table_drop ,
112
+ table_list ,
113
+ thursday ,
114
+ time ,
115
+ tuesday ,
116
+ type_of ,
117
+ union ,
118
+ uuid ,
119
+ wednesday ,
34
120
)
35
- # pylint: enable=redefined-builtin
121
+
122
+ # pylint: enable=redefined-builtin, unused-import
36
123
37
124
__version__ = "2.5.0"
38
125
39
126
# Create the r namespace object containing all query functions
40
127
r = SimpleNamespace ()
41
128
42
129
query_functions = {
43
- 'add' : add , 'and_' : and_ , 'april' : april , 'args' : args , 'asc' : asc ,
44
- 'august' : august , 'avg' : avg , 'binary' : binary , 'bit_and' : bit_and ,
45
- 'bit_not' : bit_not , 'bit_or' : bit_or , 'bit_sal' : bit_sal , 'bit_sar' : bit_sar ,
46
- 'bit_xor' : bit_xor , 'branch' : branch , 'ceil' : ceil , 'circle' : circle ,
47
- 'contains' : contains , 'count' : count , 'db' : db , 'db_create' : db_create ,
48
- 'db_drop' : db_drop , 'db_list' : db_list , 'december' : december , 'desc' : desc ,
49
- 'distance' : distance , 'distinct' : distinct , 'div' : div , 'do' : do ,
50
- 'epoch_time' : epoch_time , 'eq' : eq , 'error' : error , 'february' : february ,
51
- 'floor' : floor , 'format' : format , 'friday' : friday , 'ge' : ge , 'geojson' : geojson ,
52
- 'grant' : grant , 'group' : group , 'gt' : gt , 'http' : http , 'info' : info ,
53
- 'intersects' : intersects , 'iso8601' : iso8601 , 'january' : january , 'json' : json ,
54
- 'july' : july , 'june' : june , 'le' : le , 'line' : line , 'literal' : literal ,
55
- 'lt' : lt , 'make_timezone' : make_timezone , 'map' : map , 'march' : march ,
56
- 'max' : max , 'maxval' : maxval , 'may' : may , 'min' : min , 'minval' : minval ,
57
- 'mod' : mod , 'monday' : monday , 'mul' : mul , 'ne' : ne , 'not_' : not_ ,
58
- 'november' : november , 'now' : now , 'object' : object , 'october' : october ,
59
- 'or_' : or_ , 'point' : point , 'polygon' : polygon , 'random' : random ,
60
- 'range' : range , 'reduce' : reduce , 'round' : round , 'row' : row ,
61
- 'saturday' : saturday , 'september' : september , 'sub' : sub , 'sum' : sum ,
62
- 'sunday' : sunday , 'table' : table , 'table_create' : table_create ,
63
- 'table_drop' : table_drop , 'table_list' : table_list , 'thursday' : thursday ,
64
- 'time' : time , 'tuesday' : tuesday , 'type_of' : type_of , 'union' : union ,
65
- 'uuid' : uuid , 'wednesday' : wednesday , 'js' : js
130
+ "add" : add ,
131
+ "and_" : and_ ,
132
+ "april" : april ,
133
+ "args" : args ,
134
+ "asc" : asc ,
135
+ "august" : august ,
136
+ "avg" : avg ,
137
+ "binary" : binary ,
138
+ "bit_and" : bit_and ,
139
+ "bit_not" : bit_not ,
140
+ "bit_or" : bit_or ,
141
+ "bit_sal" : bit_sal ,
142
+ "bit_sar" : bit_sar ,
143
+ "bit_xor" : bit_xor ,
144
+ "branch" : branch ,
145
+ "ceil" : ceil ,
146
+ "circle" : circle ,
147
+ "contains" : contains ,
148
+ "count" : count ,
149
+ "db" : db ,
150
+ "db_create" : db_create ,
151
+ "db_drop" : db_drop ,
152
+ "db_list" : db_list ,
153
+ "december" : december ,
154
+ "desc" : desc ,
155
+ "distance" : distance ,
156
+ "distinct" : distinct ,
157
+ "div" : div ,
158
+ "do" : do ,
159
+ "epoch_time" : epoch_time ,
160
+ "eq" : eq ,
161
+ "error" : error ,
162
+ "february" : february ,
163
+ "floor" : floor ,
164
+ "format" : format ,
165
+ "friday" : friday ,
166
+ "ge" : ge ,
167
+ "geojson" : geojson ,
168
+ "grant" : grant ,
169
+ "group" : group ,
170
+ "gt" : gt ,
171
+ "http" : http ,
172
+ "info" : info ,
173
+ "intersects" : intersects ,
174
+ "iso8601" : iso8601 ,
175
+ "january" : january ,
176
+ "json" : json ,
177
+ "july" : july ,
178
+ "june" : june ,
179
+ "le" : le ,
180
+ "line" : line ,
181
+ "literal" : literal ,
182
+ "lt" : lt ,
183
+ "make_timezone" : make_timezone ,
184
+ "map" : map ,
185
+ "march" : march ,
186
+ "max" : max ,
187
+ "maxval" : maxval ,
188
+ "may" : may ,
189
+ "min" : min ,
190
+ "minval" : minval ,
191
+ "mod" : mod ,
192
+ "monday" : monday ,
193
+ "mul" : mul ,
194
+ "ne" : ne ,
195
+ "not_" : not_ ,
196
+ "november" : november ,
197
+ "now" : now ,
198
+ "object" : object ,
199
+ "october" : october ,
200
+ "or_" : or_ ,
201
+ "point" : point ,
202
+ "polygon" : polygon ,
203
+ "random" : random ,
204
+ "range" : range ,
205
+ "reduce" : reduce ,
206
+ "round" : round ,
207
+ "row" : row ,
208
+ "saturday" : saturday ,
209
+ "september" : september ,
210
+ "sub" : sub ,
211
+ "sum" : sum ,
212
+ "sunday" : sunday ,
213
+ "table" : table ,
214
+ "table_create" : table_create ,
215
+ "table_drop" : table_drop ,
216
+ "table_list" : table_list ,
217
+ "thursday" : thursday ,
218
+ "time" : time ,
219
+ "tuesday" : tuesday ,
220
+ "type_of" : type_of ,
221
+ "union" : union ,
222
+ "uuid" : uuid ,
223
+ "wednesday" : wednesday ,
224
+ "js" : js ,
66
225
}
67
226
68
227
for name , func in query_functions .items ():
@@ -85,7 +244,6 @@ def __init__(self):
85
244
net .Connection ._r = self
86
245
self .connection_type = None
87
246
88
- # Ensure the `make_connection` function is not overridden accidentally
89
247
self .make_connection = self .net .make_connection
90
248
self .set_loop_type (None )
91
249
@@ -103,16 +261,20 @@ def set_loop_type(self, library=None) -> None:
103
261
library = None
104
262
105
263
if library == "tornado" :
106
- warnings .warn (f"{ library } is not yet supported, using the default one" )
107
- library = None
264
+ # pylint: disable=import-outside-toplevel
265
+ from rethinkdb .net_tornado import Connection as TornadoConnection
266
+
267
+ self .connection_type = TornadoConnection
108
268
109
269
if library == "trio" :
110
270
warnings .warn (f"{ library } is not yet supported, using the default one" )
111
271
library = None
112
272
113
273
if library == "twisted" :
114
- warnings .warn (f"{ library } is not yet supported, using the default one" )
115
- library = None
274
+ # pylint: disable=import-outside-toplevel
275
+ from rethinkdb .net_twisted import Connection as TwistedConnection
276
+
277
+ self .connection_type = TwistedConnection
116
278
117
279
if library is None or self .connection_type is None :
118
280
self .connection_type = self .net .DefaultConnection
0 commit comments