Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions channelfinder/ChannelFinderClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ def set(self, **kwds):

'''
if len(kwds) == 1:
self.__hadleSingleAddParameter(**kwds)
self.__handleSingleAddParameter(**kwds)
elif len(kwds) == 2:
self.__handleMultipleAddParameters(**kwds)
else:
raise Exception, 'incorrect usage: '

def __hadleSingleAddParameter(self, **kwds):
def __handleSingleAddParameter(self, **kwds):
if 'channel' in kwds :
r = self.__session.put(self.__baseURL + self.__channelsResource + '/' + kwds['channel'][u'name'],
data=JSONEncoder().encode(kwds['channel']),
Expand Down Expand Up @@ -251,6 +251,13 @@ def find(self, **kwds):
>>> find(tagName='pattern1,pattern2')
will return all the channels which have the tags matching pattern1 AND pattern2

>>> find(size=5)
will return the first 5 channels

Basic rule for *size* and *ifrom* parameters:
(n >= 1, m >= 0)
>>> assert find(size=n, ifrom=m) == find(size=n+m)[-n:]

To query for the existance of a tag or property use findTag and findProperty.
'''
if not self.__baseURL:
Expand All @@ -272,6 +279,10 @@ def find(self, **kwds):
patterns = prop[1].split(',')
for eachPattern in patterns:
args.append((prop[0], eachPattern.strip()))
elif key == 'size':
args.append(('~size', '{0:d}'.format(int(kwds[key]))))
elif key == 'ifrom':
args.append(('~from', '{0:d}'.format(int(kwds[key]))))
else:
raise Exception, 'unknown find argument ' + key
return self.findByArgs(args)
Expand Down