Skip to content

Commit 333dfae

Browse files
committed
Renames commands to lowercase
1 parent 658169d commit 333dfae

File tree

3 files changed

+95
-83
lines changed

3 files changed

+95
-83
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,26 @@ obj = {
2828
'coord': 'out there'
2929
}
3030
}
31-
rj.JSONSet('obj', Path.rootPath(), obj)
31+
rj.jsonset('obj', Path.rootPath(), obj)
3232

3333
# Get something
3434
print 'Is there anybody... {}?'.format(
35-
rj.JSONGet('obj', Path('.truth.coord'))
35+
rj.jsonget('obj', Path('.truth.coord'))
3636
)
3737

3838
# Delete something (or perhaps nothing), append something and pop it
39-
rj.JSONDel('obj', Path('.arr[0]'))
40-
rj.JSONArrAppend('obj', Path('.arr'), 'something')
41-
print '{} popped!'.format(rj.JSONArrPop('obj', Path('.arr')))
39+
rj.jsondel('obj', Path('.arr[0]'))
40+
rj.jsonarrappend('obj', Path('.arr'), 'something')
41+
print '{} popped!'.format(rj.jsonarrpop('obj', Path('.arr')))
4242

4343
# Update something else
44-
rj.JSONSet('obj', Path('.answer'), 2.17)
44+
rj.jsonset('obj', Path('.answer'), 2.17)
45+
46+
# And use just like the regular redis-py client
47+
jp = rj.pipeline()
48+
jp.set('foo', 'bar')
49+
jp.jsonset('baz', Path.rootPath(), 'qaz')
50+
jp.execute()
4551

4652
```
4753

rejson/client.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ def setDecoder(self, decoder):
105105
self._decoder = decoder
106106
self._decode = self._decoder.decode
107107

108-
def JSONDel(self, name, path=Path.rootPath()):
108+
def jsondel(self, name, path=Path.rootPath()):
109109
"""
110110
Deletes the JSON value stored at key ``name`` under ``path``
111111
"""
112112
return self.execute_command('JSON.DEL', name, str_path(path))
113113

114-
def JSONGet(self, name, *args):
114+
def jsonget(self, name, *args):
115115
"""
116116
Get the object stored as a JSON value at key ``name``
117117
``args`` is zero or more paths, and defaults to root path
@@ -124,7 +124,7 @@ def JSONGet(self, name, *args):
124124
pieces.append(str_path(p))
125125
return self.execute_command('JSON.GET', *pieces)
126126

127-
def JSONMGet(self, path, *args):
127+
def jsonmget(self, path, *args):
128128
"""
129129
Gets the objects stored as a JSON values under ``path`` from
130130
keys ``args``
@@ -134,7 +134,7 @@ def JSONMGet(self, path, *args):
134134
pieces.append(str_path(path))
135135
return self.execute_command('JSON.MGET', *pieces)
136136

137-
def JSONSet(self, name, path, obj, nx=False, xx=False):
137+
def jsonset(self, name, path, obj, nx=False, xx=False):
138138
"""
139139
Set the JSON value at key ``name`` under the ``path`` to ``obj``
140140
``nx`` if set to True, set ``value`` only if it does not exist
@@ -152,41 +152,41 @@ def JSONSet(self, name, path, obj, nx=False, xx=False):
152152
pieces.append('XX')
153153
return self.execute_command('JSON.SET', *pieces)
154154

155-
def JSONType(self, name, path=Path.rootPath()):
155+
def jsontype(self, name, path=Path.rootPath()):
156156
"""
157157
Gets the type of the JSON value under ``path`` from key ``name``
158158
"""
159159
return self.execute_command('JSON.TYPE', name, str_path(path))
160160

161-
def JSONNumIncrBy(self, name, path, number):
161+
def jsonnumincrby(self, name, path, number):
162162
"""
163163
Increments the numeric (integer or floating point) JSON value under
164164
``path`` at key ``name`` by the provided ``number``
165165
"""
166166
return self.execute_command('JSON.NUMINCRBY', name, str_path(path), self._encode(number))
167167

168-
def JSONNumMultBy(self, name, path, number):
168+
def jsonnummultby(self, name, path, number):
169169
"""
170170
Multiplies the numeric (integer or floating point) JSON value under
171171
``path`` at key ``name`` with the provided ``number``
172172
"""
173173
return self.execute_command('JSON.NUMMULTBY', name, str_path(path), self._encode(number))
174174

175-
def JSONStrAppend(self, name, string, path=Path.rootPath()):
175+
def jsonstrappend(self, name, string, path=Path.rootPath()):
176176
"""
177177
Appends to the string JSON value under ``path`` at key ``name`` the
178178
provided ``string``
179179
"""
180180
return self.execute_command('JSON.STRAPPEND', name, str_path(path), self._encode(string))
181181

182-
def JSONStrLen(self, name, path=Path.rootPath()):
182+
def jsonstrlen(self, name, path=Path.rootPath()):
183183
"""
184184
Returns the length of the string JSON value under ``path`` at key
185185
``name``
186186
"""
187187
return self.execute_command('JSON.STRLEN', name, str_path(path))
188188

189-
def JSONArrAppend(self, name, path=Path.rootPath(), *args):
189+
def jsonarrappend(self, name, path=Path.rootPath(), *args):
190190
"""
191191
Appends the objects ``args`` to the array under the ``path` in key
192192
``name``
@@ -196,15 +196,15 @@ def JSONArrAppend(self, name, path=Path.rootPath(), *args):
196196
pieces.append(self._encode(o))
197197
return self.execute_command('JSON.ARRAPPEND', *pieces)
198198

199-
def JSONArrIndex(self, name, path, scalar, start=0, stop=-1):
199+
def jsonarrindex(self, name, path, scalar, start=0, stop=-1):
200200
"""
201201
Returns the index of ``scalar`` in the JSON array under ``path`` at key
202202
``name``. The search can be limited using the optional inclusive
203203
``start`` and exclusive ``stop`` indices.
204204
"""
205205
return self.execute_command('JSON.ARRINDEX', name, str_path(path), self._encode(scalar), start, stop)
206206

207-
def JSONArrInsert(self, name, path, index, *args):
207+
def jsonarrinsert(self, name, path, index, *args):
208208
"""
209209
Inserts the objects ``args`` to the array at index ``index`` under the
210210
``path` in key ``name``
@@ -214,35 +214,35 @@ def JSONArrInsert(self, name, path, index, *args):
214214
pieces.append(self._encode(o))
215215
return self.execute_command('JSON.ARRINSERT', *pieces)
216216

217-
def JSONArrLen(self, name, path=Path.rootPath()):
217+
def jsonarrlen(self, name, path=Path.rootPath()):
218218
"""
219219
Returns the length of the array JSON value under ``path`` at key
220220
``name``
221221
"""
222222
return self.execute_command('JSON.ARRLEN', name, str_path(path))
223223

224-
def JSONArrPop(self, name, path=Path.rootPath(), index=-1):
224+
def jsonarrpop(self, name, path=Path.rootPath(), index=-1):
225225
"""
226226
Pops the element at ``index`` in the array JSON value under ``path`` at
227227
key ``name``
228228
"""
229229
return self.execute_command('JSON.ARRPOP', name, str_path(path), index)
230230

231-
def JSONArrTrim(self, name, path, start, stop):
231+
def jsonarrtrim(self, name, path, start, stop):
232232
"""
233233
Trim the array JSON value under ``path`` at key ``name`` to the
234234
inclusive range given by ``start`` and ``stop``
235235
"""
236236
return self.execute_command('JSON.ARRTRIM', name, str_path(path), start, stop)
237237

238-
def JSONObjKeys(self, name, path=Path.rootPath()):
238+
def jsonobjkeys(self, name, path=Path.rootPath()):
239239
"""
240240
Returns the key names in the dictionary JSON value under ``path`` at key
241241
``name``
242242
"""
243243
return self.execute_command('JSON.OBJKEYS', name, str_path(path))
244244

245-
def JSONObjLen(self, name, path=Path.rootPath()):
245+
def jsonobjlen(self, name, path=Path.rootPath()):
246246
"""
247247
Returns the length of the dictionary JSON value under ``path`` at key
248248
``name``

0 commit comments

Comments
 (0)