

def __init__(self, name, trait_cfg, plugin_map):
    self.cfg = trait_cfg
    self.name = name
    type_name = None
    try:
        type_name = trait_cfg.get('type', 'text')
    except AttributeError as e:
        raise EventDefinitionException(("Unable to get type for '%s'" % trait_cfg), self.cfg)
    if ('plugin' in trait_cfg):
        plugin_cfg = trait_cfg['plugin']
        if isinstance(plugin_cfg, six.string_types):
            plugin_name = plugin_cfg
            plugin_params = {
                
            }
        else:
            try:
                plugin_name = plugin_cfg['name']
            except KeyError:
                raise EventDefinitionException(('Plugin specified, but no plugin name supplied for trait %s' % name), self.cfg)
            plugin_params = plugin_cfg.get('parameters')
            if (plugin_params is None):
                plugin_params = {
                    
                }
        try:
            plugin_class = plugin_map[plugin_name]
        except KeyError:
            raise EventDefinitionException(('No plugin named %(plugin)s available for trait %(trait)s' % dict(plugin=plugin_name, trait=name)), self.cfg)
        self.plugin = plugin_class(**plugin_params)
    else:
        self.plugin = None
    if ('fields' not in trait_cfg):
        raise EventDefinitionException(("Required field in trait definition not specified: '%s'" % 'fields'), self.cfg)
    fields = trait_cfg['fields']
    if (not isinstance(fields, six.string_types)):
        if (len(fields) == 1):
            fields = fields[0]
        else:
            fields = '|'.join((('(%s)' % path) for path in fields))
    try:
        self.fields = jsonpath_rw.parse(fields)
    except Exception as e:
        raise EventDefinitionException(("Parse error in JSONPath specification '%(jsonpath)s' for %(trait)s: %(err)s" % dict(jsonpath=fields, trait=name, err=e)), self.cfg)
    try:
        self.trait_type = Datatype[type_name]
    except KeyError:
        raise EventDefinitionException(("Invalid trait type '%(type)s' for trait %(trait)s" % dict(type=type_name, trait=name)), self.cfg)

dataset/ETHPy150Open openstack/stacktach-stackdistiller/stackdistiller/distiller.py TraitDefinition.__init__/original