Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@specs.inject('to_list', yaqltypes.Delegate('to_list', method=True))
def split_where(collection, predicate, to_list):
""":yaql:splitWhere
Returns collection divided into list of collections where delimiters are
values for which predicate returns true. Delimiters are deleted from
result.
:signature: collection.splitWhere(predicate)
:receiverArg collection: input collection
:argType collection: iterable
:arg predicate: function of one argument to be applied on every
element. Elements for which predicate returns true are delimiters for
new list
:argType predicate: lambda
:returnType: list
@specs.inject('operator', yaqltypes.Delegate('#operator_>'))
def max_(a, b, operator):
if operator(b, a):
return b
return a
@specs.inject('operator', yaqltypes.Super(with_context=True))
@specs.name('#operator_.')
def op_dot_static(context, receiver, expr, operator):
executor = helpers.get_executor()
type_context = executor.context_manager.create_type_context(
receiver.type)
ctx2 = helpers.link_contexts(context, type_context)
return operator(ctx2, receiver, expr)
@specs.inject('str_delegate', yaqltypes.Delegate('str'))
@specs.method
def join_(separator, sequence, str_delegate):
""":yaql:join
Returns a string with sequence elements joined by the separator.
:signature: separator.join(sequence)
:receiverArg separator: value to be placed between joined pairs
:argType separator: string
:arg sequence: chain of values to be joined
:argType sequence: sequence of strings
:returnType: string
.. code::
yaql> "|".join(["abc", "de", "f"])
@specs.inject('delegate', yaqltypes.Super(with_name=True))
@specs.no_kwargs
@specs.extension_method
def dict_(delegate, *tuples):
""":yaql:dict
Returns dict built from tuples.
:signature: dict([args])
:arg [args]: chain of tuples to be interpreted as (key, value) for dict
:argType [args]: chain of tuples
:returnType: dictionary
.. code::
yaql> dict(a => 1, b => 2)
{"a": 1, "b": 2}
@specs.inject('receiver', yaqltypes.Receiver())
@specs.meta(constants.META_NO_TRACE, True)
def json(cls, receiver, name, owner=None):
return jsonlib.loads(cls.string(receiver, name, owner))