Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@specs.name('type')
@specs.parameter('object_', dsl.MuranoObjectParameter(nullable=True))
def type_legacy(object_):
return None if object_ is None else object_.type.name
@specs.name('name')
def argument_name(method_argument):
return method_argument.name
@specs.name('datetime')
@specs.parameter('string', yaqltypes.String())
@specs.parameter('format__', yaqltypes.String(True))
def datetime_from_string(string, format__=None):
if not format__:
result = parser.parse(string)
else:
result = DATETIME_TYPE.strptime(string, format__)
if not result.tzinfo:
return result.replace(tzinfo=UTCTZ)
return result
@specs.name('#unary_operator_:')
def ns_resolve_unary(context, name):
return ns_resolve(context, '', name)
@specs.name('keys')
@specs.method
def dict_keys(d):
""":yaql:keys
Returns an iterator over the dictionary keys.
:signature: dict.keys()
:receiverArg dict: input dictionary
:argType dict: dictionary
:returnType: iterator
.. code::
yaql> {"a" => 1, "b" => 2}.keys()
["a", "b"]
"""
@specs.name('#operator_.')
def collection_attribution(collection, attribute, operator):
""":yaql:operator .
Retrieves the value of an attribute for each element in a collection and
returns a list of results.
:signature: collection.attribute
:arg collection: input collection
:argType collection: iterable
:arg attribute: attribute to get on every collection item
:argType attribute: keyword
:returnType: list
.. code::
yaql> [{"a" => 1}, {"a" => 2, "b" => 3}].a
@specs.name('replace')
def replace_string(string, regexp, repl, count=0):
return replace(regexp, string, repl, count)
@specs.name('#finalize')
def finalize(obj):
if isinstance(obj, dict):
obj.pop('_notNull', None)
return obj
@specs.name('#operator_:')
def ns_resolve(context, prefix, name):
return _wrap_type_reference(
yaql_functions.ns_resolve(context, prefix, name), context)