Пример #1
0
 def get_params():
     return [
         params.ParamDescriptor('zk_host', type_util.String(), 'localhost'),
         params.ParamDescriptor('zk_port', type_util.Number(), 2181),
         params.ParamDescriptor('group_id', type_util.String(),
                                'my_group_id'),
         params.ParamDescriptor('topics',
                                type_util.Object(strict_checking=False))
     ]
 def get_params():
     return [
         params.ParamDescriptor('host', type_util.String(), 'localhost'),
         params.ParamDescriptor('port', type_util.Number(), 1010),
         params.ParamDescriptor(
             'model',
             type_util.Object({
                 'name':
                 type_util.String(),
                 'params':
                 type_util.Object({
                     'origin_types':
                     type_util.Object(strict_checking=False)
                 })
             })),
         params.ParamDescriptor('alert_per_burst', type_util.Number(), 1),
         params.ParamDescriptor('idle_time_between_bursts',
                                type_util.Number(), 1.0),
     ]
 def get_params():
     return [
         params.ParamDescriptor('sleep', type_util.Number(), 0.01),
         params.ParamDescriptor('min_event_per_burst', type_util.Number(),
                                500),
         params.ParamDescriptor(
             'transitions',
             type_util.Object({
                 'web_service':
                 type_util.Object({
                     'run=>slow': type_util.Any(),
                     'slow=>run': type_util.Any(),
                     'stop=>run': type_util.Any(),
                 }),
                 'switch':
                 type_util.Object({
                     'on=>off': type_util.Number(),
                     'off=>on': type_util.Number(),
                 }),
                 'host':
                 type_util.Object({
                     'on=>off': type_util.Number(),
                     'off=>on': type_util.Number(),
                 })
             })),
         params.ParamDescriptor(
             'triggers',
             type_util.Object({
                 'support':
                 type_util.Object({'get_called': type_util.Any()})
             })),
         params.ParamDescriptor('graph', type_util.Any())
     ]
Пример #4
0
def typeck_jsonobj(json_obj, type_table):
    """
    Type-check a json-like object. If it succeeds
    it return the appropriate type describing this
    json like object. Raise an exception otherwise.
    :type json_obj: ast.JsonObj
    :param json_obj: The JsonObj ast node.
    :type type_table: typetbl.TypeTable
    :param type_table: The type table.
    :rtype: u.Object
    :return: Returns an instance of util.Object describing
             the full type of this json object.
    """
    root_type = u.Object(strict_checking=False)

    for k, v in json_obj.props.iteritems():
        sub_type = u.create_object_tree(k, typeck_rhs(v, type_table))
        u.attach_to_root(root_type, sub_type, json_obj.span)

    return root_type