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('func', yaqltypes.Delegate(use_convention=False))
def get_property(func, obj, name):
""":yaql:operator .
Returns value of 'name' property.
:signature: left.right
:arg left: object
:argType left: any
:arg right: object property name
:argType right: keyword
:returnType: any
.. code::
yaql> now().year
2016
@specs.inject('str_delegate', yaqltypes.Delegate('str'))
@specs.method
def join(sequence, separator, str_delegate):
""":yaql:join
Returns a string with sequence elements joined by the separator.
:signature: sequence.join(separator)
:receiverArg sequence: chain of values to be joined
:argType sequence: sequence of strings
:arg separator: value to be placed between joined pairs
:argType separator: string
:returnType: string
.. code::
yaql> ["abc", "de", "f"].join("")
@specs.inject('delegate', yaqltypes.Delegate('to_set', method=True))
def set_(delegate, *args):
""":yaql:set
Returns set initialized with args.
:signature: set([args])
:arg [args]: args to build a set
:argType [args]: chain of any type
:returnType: set
.. code::
yaql> set(0, "", [1, 2])
[0, "", [1, 2]]
"""
def rec(seq):
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from oslo_log import log as logging
from yaql.language import specs
from yaql.language import yaqltypes
from murano.dsl import dsl
NAME_TEMPLATE = u'applications.{0}'
inject_format = specs.inject(
'_Logger__yaql_format_function',
yaqltypes.Delegate('format'))
@dsl.name('io.murano.system.Logger')
class Logger(object):
"""Logger object for MuranoPL.
Instance of this object returned by 'logger' YAQL function
and should not be instantiated directly
"""
def __init__(self, logger_name):
self._underlying_logger = logging.getLogger(
NAME_TEMPLATE.format(logger_name))
@specs.parameter('_Logger__message', yaqltypes.String())
@inject_format
@specs.inject('delegate', yaqltypes.Delegate('substring', method=True))
@specs.extension_method
def substr(delegate, string, start, length=-1):
return delegate(string, start, length)
@specs.inject('delegate', yaqltypes.Delegate('to_list', method=True))
def list_(delegate, *args):
""":yaql:list
Returns list of provided args and unpacks arg element if it's iterable.
:signature: list([args])
:arg [args]: arguments to create a list
:argType [args]: chain of any types
:returnType: list
.. code::
yaql> list(1, "", range(2))
[1, "", 0, 1]
"""
def rec(seq):
@specs.inject('operator_gt', yaqltypes.Delegate('#operator_>'))
@specs.inject('operator_lt', yaqltypes.Delegate('#operator_<'))
@specs.method
def order_by(collection, selector, operator_lt, operator_gt):
""":yaql:orderBy
Returns an iterator over collection elements sorted in ascending order.
Selector is applied to each element of the collection to extract
sorting key.
:signature: collection.orderBy(selector)
:receiverArg collection: collection to be ordered
:argType collection: iterable
:arg selector: specifies a function of one argument that is used to
extract a comparison key from each element
:argType selector: lambda
:returnType: iterator
@specs.inject('func', yaqltypes.Delegate('min'))
@specs.method
def min_(func, collection, initial=utils.NO_VALUE):
""":yaql:min
Returns min value in collection. Considers initial if specified.
:signature: collection.min(initial => NoValue)
:receiverArg collection: input collection
:argType collection: iterable
:arg initial: value to start with. NoValue by default
:argType initial: collection's elements type
:returnType: collection's elements type
.. code::
yaql> [3, 1, 2].min()
@specs.inject('limiter', yaqltypes.Delegate('#iter'))
@specs.inject('engine', yaqltypes.Engine())
@specs.name('#finalize')
def finalize(obj, limiter, engine):
if engine.options.get('yaql.convertOutputData', True):
return utils.convert_output_data(obj, limiter, engine)
return obj