Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def signature_from_cstruct(self, cstruct, format):
name = cstruct.get('dest')
keys = cstruct.get('keys')
if keys and format == 'dict':
keys = dict(keys)
if keys and format == 'list':
keys = [x[0] for x in keys]
aggregate = cstruct.get('aggregate')
return ([name, keys], {'aggregate': aggregate})
DestKeysAggregateSchema = DestKeysAggregateSchemaNode(LarkMappingSchema())
node(DestKeysAggregateSchema, name_ref_type, name='dest')
DestKeysAggregateSchema.add(LarkSchemaNode(colander.Sequence(), NameWeightTupleSchema, name='keys'))
node(DestKeysAggregateSchema, lark_string, name='aggregate', missing=None)
KeyValueTupleSchema = colander.SchemaNode(colander.Tuple())
KeyValueTupleSchema.add(colander.SchemaNode(lark_string, name='key'))
KeyValueTupleSchema.add(colander.SchemaNode(value_type, name='value'))
class NameMappingSchemaNode(LarkSchemaNode):
def from_request(self, args=None, kwargs=None, query_dict=None, request_json=None, redis_prefix=None):
request_json = request_json if request_json else {}
mapping = request_json.get('mapping')
NameKeysSchema = NameKeysSchemaNode(LarkMappingSchema())
node(NameKeysSchema, name_ref_type, name='name')
NameKeysSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(lark_string), name='key'))
class DestKeysSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
dest = cstruct['dest']
keys = cstruct['keys']
return ([dest, keys], {})
DestKeysSchema = DestKeysSchemaNode(LarkMappingSchema())
node(DestKeysSchema, name_ref_type, name='dest')
DestKeysSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(lark_string), name='keys'))
class OperationDestKeysSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
operation = cstruct['operation']
dest = cstruct['dest']
keys = cstruct['keys']
return ([operation, dest] + keys, {})
OperationDestKeysSchema = OperationDestKeysSchemaNode(LarkMappingSchema())
node(OperationDestKeysSchema, name_ref_type, name='operation')
node(OperationDestKeysSchema, name_ref_type, name='dest')
PatternSchema = LarkSchemaNode(LarkMappingSchema())
node(PatternSchema, name_ref_type, name='pattern', missing='*')
KeySchema = LarkSchemaNode(LarkMappingSchema())
node(KeySchema, name_ref_type, name='key')
class KeySchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
return (cstruct['key'], {})
KeysSchema = KeySchemaNode(LarkMappingSchema())
KeysSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(name_ref_type), name='key'))
KeyListSchema = LarkSchemaNode(LarkMappingSchema())
KeyListSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(name_ref_type), name='key'))
KeysTimeoutSchema = LarkSchemaNode(LarkMappingSchema())
KeysTimeoutSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(name_ref_type), name='keys'))
node(KeysTimeoutSchema, int_type, name='timeout')
ValueSchema = LarkSchemaNode(LarkMappingSchema())
node(ValueSchema, value_type, name='value')
NameAmountSchema = LarkSchemaNode(LarkMappingSchema())
node(NameAmountSchema, name_ref_type, name='name')
node(NameAmountSchema, name_ref_type, name='amount', missing=1)
DestKeysSchema = DestKeysSchemaNode(LarkMappingSchema())
node(DestKeysSchema, name_ref_type, name='dest')
DestKeysSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(lark_string), name='keys'))
class OperationDestKeysSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
operation = cstruct['operation']
dest = cstruct['dest']
keys = cstruct['keys']
return ([operation, dest] + keys, {})
OperationDestKeysSchema = OperationDestKeysSchemaNode(LarkMappingSchema())
node(OperationDestKeysSchema, name_ref_type, name='operation')
node(OperationDestKeysSchema, name_ref_type, name='dest')
OperationDestKeysSchema.add(LarkSchemaNode(colander.Sequence(), LarkSchemaNode(lark_string), name='keys'))
NameWeightTupleSchema = colander.SchemaNode(colander.Tuple())
NameWeightTupleSchema.add(colander.SchemaNode(lark_string, name='name'))
NameWeightTupleSchema.add(colander.SchemaNode(int_type, name='weight', missing=None))
class DestKeysAggregateSchemaNode(LarkSchemaNode):
def from_request(self, args=None, kwargs=None, query_dict=None, request_json=None, redis_prefix=None):
keys = request_json.get('keys')
format = 'dict'
if keys and isinstance(keys, dict):
InfotypeKeyScheam = LarkSchemaNode(LarkMappingSchema())
node(InfotypeKeyScheam, lark_string, name='infotype')
node(InfotypeKeyScheam, name_ref_type, name='key')
NameSchema = LarkSchemaNode(LarkMappingSchema())
node(NameSchema, name_ref_type, name='name')
class NamesSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
return (cstruct['name'], {})
NamesSchema = NamesSchemaNode(LarkMappingSchema())
NamesSchema.add(LarkSchemaNode(colander.Sequence(accept_scalar=True), LarkSchemaNode(name_ref_type), name='name'))
PatternSchema = LarkSchemaNode(LarkMappingSchema())
node(PatternSchema, name_ref_type, name='pattern', missing='*')
KeySchema = LarkSchemaNode(LarkMappingSchema())
node(KeySchema, name_ref_type, name='key')
class KeySchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
return (cstruct['key'], {})
min = cstruct.get('min')
max = cstruct.get('max')
start = cstruct.get('start')
num = cstruct.get('num')
withscores = cstruct.get('withscores')
score_cast_func = valid_cast_funcs.get(cstruct.get('score_cast_func'))
# print 'Sendcing up score_cast_func: %s %s' % (score_cast_func, type(score_cast_func))
return ([name, min, max], {
'start': start,
'num': num,
'withscores': withscores,
'score_cast_func': score_cast_func,
})
ZrangeByScoresSchema = ZrangeByScoresSchemaNode(LarkMappingSchema())
node(ZrangeByScoresSchema, name_ref_type, name='name')
node(ZrangeByScoresSchema, int_type, name='min')
node(ZrangeByScoresSchema, int_type, name='max')
node(ZrangeByScoresSchema, int_type, name='start', missing=None)
node(ZrangeByScoresSchema, int_type, name='num', missing=None)
node(ZrangeByScoresSchema, string_bool, name='withscores', missing=False)
node(ZrangeByScoresSchema, lark_string, name='score_cast_func', missing='float')
class ZrevRangeSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_keys, redis_args):
name = cstruct.get('name')
start = cstruct.get('start')
end = cstruct.get('end')
withscores = cstruct.get('withscores')
score_cast_func = valid_cast_funcs.get(cstruct.get('score_cast_func'))
class ZrangeSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_keys, redis_args):
name = cstruct.get('name')
start = cstruct.get('start')
end = cstruct.get('end')
desc = cstruct.get('desc')
withscores = cstruct.get('withscores')
score_cast_func = valid_cast_funcs.get(cstruct.get('score_cast_func'))
return ([name, start, end], {
'desc': desc,
'withscores': withscores,
'score_cast_func': score_cast_func,
})
ZrangeSchema = ZrangeSchemaNode(LarkMappingSchema())
node(ZrangeSchema, name_ref_type, name='name')
node(ZrangeSchema, int_type, name='start')
node(ZrangeSchema, int_type, name='end')
node(ZrangeSchema, string_bool, name='desc', missing=False)
node(ZrangeSchema, string_bool, name='withscores', missing=False)
node(ZrangeSchema, lark_string, name='score_cast_func', missing='float')
NameTtlBinValueSchema = LarkSchemaNode(LarkMappingSchema())
node(NameTtlBinValueSchema, name_ref_type, name='name')
node(NameTtlBinValueSchema, int_type, name='ttl')
node(NameTtlBinValueSchema, bin_type, name='value')
class ZrevRangeSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_keys, redis_args):
name = cstruct.get('name')
start = cstruct.get('start')
end = cstruct.get('end')
withscores = cstruct.get('withscores')
score_cast_func = valid_cast_funcs.get(cstruct.get('score_cast_func'))
return ([name, start, end], {
'withscores': withscores,
'score_cast_func': score_cast_func,
})
ZrevRangeSchema = ZrevRangeSchemaNode(LarkMappingSchema())
node(ZrevRangeSchema, name_ref_type, name='name')
node(ZrevRangeSchema, int_type, name='start')
node(ZrevRangeSchema, int_type, name='end')
node(ZrevRangeSchema, string_bool, name='withscores', missing=False)
node(ZrevRangeSchema, lark_string, name='score_cast_func', missing='float')
class ZrangeSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_keys, redis_args):
name = cstruct.get('name')
start = cstruct.get('start')
end = cstruct.get('end')
desc = cstruct.get('desc')
withscores = cstruct.get('withscores')
score_cast_func = valid_cast_funcs.get(cstruct.get('score_cast_func'))
return ([name, start, end], {
cstruct = {
'value': request_json
}
# print "Going to deserialize: %s" % (cstruct)
self.redis_prefix = redis_prefix
data = self.deserialize(cstruct)
args, kwargs = self.signature_from_cstruct(data)
return (args, kwargs)
def signature_from_cstruct(self, cstruct):
values = cstruct['value']
return ([], dict(values))
NameValueListSchema = NameValueListSchemaNode(LarkMappingSchema())
NameValueListSchema.add(LarkSchemaNode(colander.Sequence(), NameValueTupleSchema, name='value'))
NameScoreTupleSchema = colander.SchemaNode(colander.Tuple())
NameScoreTupleSchema.add(colander.SchemaNode(lark_string, name='name'))
NameScoreTupleSchema.add(colander.SchemaNode(lark_string, name='score'))
class NameScoreListSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
name = cstruct['name']
scores = cstruct['scores']
return ([name], dict(scores))
NameScoreTupleSchema = colander.SchemaNode(colander.Tuple())
NameScoreTupleSchema.add(colander.SchemaNode(lark_string, name='name'))
NameScoreTupleSchema.add(colander.SchemaNode(lark_string, name='score'))
class NameScoreListSchemaNode(LarkSchemaNode):
def signature_from_cstruct(self, cstruct, redis_args, redis_kwargs):
name = cstruct['name']
scores = cstruct['scores']
return ([name], dict(scores))
NameScoreListSchema = NameScoreListSchemaNode(LarkMappingSchema())
NameScoreListSchema.add(LarkSchemaNode(name_ref_type, name='name'))
NameScoreListSchema.add(LarkSchemaNode(colander.Sequence(), NameValueTupleSchema, name='scores'))
NoSchema = LarkSchemaNode(LarkMappingSchema())
AddressSchema = LarkSchemaNode(LarkMappingSchema())
node(AddressSchema, lark_string, name='address')
InfotypeKeyScheam = LarkSchemaNode(LarkMappingSchema())
node(InfotypeKeyScheam, lark_string, name='infotype')
node(InfotypeKeyScheam, name_ref_type, name='key')