Create and return an instance of the given plugin.
776860
def create_instance(self, plugin_type, plugin_name, **instance_kwargs):
        """"""
        plugin_type = self._get_plugin_type(plugin_type)
        return plugin_type.create_instance(plugin_name, **instance_kwargs)
1243563
def install(self, plugin, name=None, **opts):
        """"""
        source = plugin

        if isinstance(plugin, str):
            module, _, attr = plugin.partition(':')
            module = import_module(module)
            plugin = getattr(module, attr or 'Plugin', None)

        if isinstance(plugin, types.ModuleType):
            plugin = getattr(module, 'Plugin', None)

        if plugin is None:
            raise MuffinException('Plugin is not found %r' % source)

        name = name or plugin.name
        if name in self.ps:
            raise MuffinException('Plugin with name `%s` is already intalled.' % name)

        if isinstance(plugin, type):
            plugin = plugin(**opts)

        if hasattr(plugin, 'setup'):
            plugin.setup(self)

        if hasattr(plugin, 'middleware') and plugin.middleware not in self.middlewares:
            self.middlewares.append(plugin.middleware)

        if hasattr(plugin, 'startup'):
            self.on_startup.append(plugin.startup)

        if hasattr(plugin, 'cleanup'):
            self.on_cleanup.append(plugin.cleanup)

        # Save plugin links
        self.ps[name] = plugin

        return plugin
203057
def copy(self):
        
        cls = self.__class__
        result = cls.__new__(cls)
        result._default_plugins = dict(self._default_plugins)  # pylint:disable=protected-access
        return result
536925
def make_instance(self, data):
        """"""
        if not self.opts.model:
            return data

        if self.instance is not None:
            for key, value in data.items():
                setattr(self.instance, key, value)
            return self.instance

        return self.opts.model(**data)
786161
def register_plugin(name, &block)
      plugin = Plugin.new
      plugin.instance_eval(&block)
      @plugins[name] = plugin
    end
94924
def from_name(cls, fullname, soco, *args, **kwargs):
        """"""

        _LOG.info('Loading plugin %s', fullname)

        parts = fullname.split('.')
        modname = '.'.join(parts[:-1])
        clsname = parts[-1]

        mod = importlib.import_module(modname)
        class_ = getattr(mod, clsname)

        _LOG.info('Loaded class %s', class_)

        return class_(soco, *args, **kwargs)
809440
protected <T> T createInstance(String typeName) throws PluginRepositoryException {
        Class<T> type = getType(typeName.trim());
        try {
            return type.newInstance();
        } catch (InstantiationException e) {
            throw new PluginRepositoryException("Cannot create instance of class " + type.getName(), e);
        } catch (IllegalAccessException e) {
            throw new PluginRepositoryException("Cannot access class " + typeName, e);
        } catch (LinkageError e) {
            throw new PluginRepositoryException("Cannot load plugin class " + typeName, e);
        }
    }
756303
def use(self, plugin, arguments={}):
    
    self.plugins[plugin] = dict(arguments)
    return self.plugins
18866
def add_plugin(self, plugin, call):
        
        meth = getattr(plugin, call, None)
        if meth is not None:
            self.plugins.append((plugin, meth))
772854
function copyPlugin(plugin_src_dir, plugins_dir, link, pluginInfoProvider) {
    var pluginInfo = new PluginInfo(plugin_src_dir);
    var dest = path.join(plugins_dir, pluginInfo.id);
    shell.rm('-rf', dest);
    if (link) {
        events.emit('verbose', 'Symlinking from location "' + plugin_src_dir + '" to location "' + dest + '"');
        shell.mkdir('-p', path.dirname(dest));
        fs.symlinkSync(plugin_src_dir, dest, 'dir');
    } else {
        shell.mkdir('-p', dest);
        events.emit('verbose', 'Copying from location "' + plugin_src_dir + '" to location "' + dest + '"');
        shell.cp('-R', path.join(plugin_src_dir, '*') , dest);
    }
    pluginInfo.dir = dest;
    pluginInfoProvider.put(pluginInfo);

    return dest;
}
248376
def pluggable(method):
    
    def wrapped(self, *args, **kwargs):
        if hasattr(self, "_plugins"):
            # call the last plugin, it may call the previous via self.parent.method
            # creating a call call chain
            return getattr(self._plugins[-1], method.__name__)(*args, **kwargs)
        else:
            return method(self, *args, **kwargs)
    wrapped.original = method
    return wrapped
941111
def start_plugin(file_path=None):
    """"""
    if os.getenv('CONFIG_PATH'):
        file_path = os.getenv('CONFIG_PATH')
    else:
        file_path = file_path
    if file_path is not None:
        config = parse_config(file_path)
        plugin_instance = load_plugin(config)
    else:
        plugin_instance = load_plugin
    return plugin_instance
504884
function Plugin(regexp, replacer, id) {
    // return value should be a callable function
    // with strictly defined options passed by markdown-it
    var self = function(md, options) {
        self.options = options;
        self.init(md);
    };

    // initialize plugin object
    self.__proto__ = Plugin.prototype;

    // clone regexp with all the flags
    var flags = (regexp.global ? 'g' : '') + (regexp.multiline ? 'm' : '') + (regexp.ignoreCase ? 'i' : '');

    self.regexp = RegExp('^' + regexp.source, flags);

    // copy init options
    self.replacer = replacer;

    // this plugin can be inserted multiple times,
    // so we're generating unique name for it
    self.id = id ? id : 'regexp-' + counter;
    counter++;

    return self;
}
485477
def create(self, name, plugin_name, plugin_version, flavor_id,
               description=None, volumes_per_node=None, volumes_size=None,
               node_processes=None, node_configs=None, floating_ip_pool=None,
               security_groups=None, auto_security_group=None,
               availability_zone=None, volumes_availability_zone=None,
               volume_type=None, image_id=None, is_proxy_gateway=None,
               volume_local_to_instance=None, use_autoconfig=None,
               shares=None, is_public=None, is_protected=None,
               volume_mount_prefix=None, boot_from_volume=None,
               boot_volume_type=None, boot_volume_availability_zone=None,
               boot_volume_local_to_instance=None):
        """"""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'plugin_version': plugin_version,
            'flavor_id': flavor_id,
            'node_processes': node_processes
        }

        return self._do_create(data, description, volumes_per_node,
                               volumes_size, node_configs, floating_ip_pool,
                               security_groups, auto_security_group,
                               availability_zone, volumes_availability_zone,
                               volume_type, image_id, is_proxy_gateway,
                               volume_local_to_instance, use_autoconfig,
                               shares, is_public, is_protected,
                               volume_mount_prefix, boot_from_volume,
                               boot_volume_type,
                               boot_volume_availability_zone,
                               boot_volume_local_to_instance)
478472
def create(name, options = {})
            last_slash = name.rindex("/")
            category = name[0 ... last_slash]
            plugin = name[last_slash .. -1]

            map = @plugins[category]
            if not map
                raise "Plugin category #{category} does not exist"
            elsif not map.has_key? plugin
                raise "Plugin #{plugin} does not exist in category #{category}"
            else
                map[plugin].new(options)
            end
        end
169991
def load_base(namespace, plugin_type, provider, options = {})
    logger.info("Fetching plugin #{namespace} #{plugin_type} provider #{provider} at #{Time.now}")

    type_info  = loaded_plugin(namespace, plugin_type, provider)
    options    = translate_type(type_info, options)
    config     = Config.ensure(options)

    provider   = config.get(:provider, provider)
    name       = config.get(:name, nil)
    ensure_new = config.get(:new, false)

    if name
      logger.debug("Looking up existing instance of #{name}")

      if existing_instance = get(namespace, plugin_type, name)
        unless ensure_new
          config.delete(:new)

          config.export.each do |property_name, value|
            unless [ :name, :meta ].include?(property_name)
              existing_instance[property_name] = value
            end
          end
          existing_instance.normalize(true)

          logger.debug("Using existing instance of #{plugin_type}, #{name}")
          return existing_instance
        end
      end
    end
    create(namespace, plugin_type, provider, config)
  end
594209
function pluginFactory(cache) {

  // ensure cache
  var internalCache = cache || {};

  // create an instance of cache populater
  var getCache = cacheFactory(internalCache);

  // return a closure with a pluginFactory() sidecar
  browserifyIncremental.pluginFactory = pluginFactory;
  return browserifyIncremental;

  /**
   * A browserify plugin that checks incoming file context and uses cached results.
   * @param {object} bundler The browserify bundler instance
   * @param {object} opt An options hash
   */
  function browserifyIncremental(bundler, opt) {
    var isValid = bundler && (typeof bundler === 'object') &&
      (typeof bundler.on === 'function') && (typeof bundler.pipeline === 'object');
    if (isValid) {
      bundler.on('reset', setupPipeline);
      setupPipeline();
    }
    else {
      throw new Error('Expected a browserify bundler instance')
    }

    /**
     * Apply an interceptor to the pipeline.
     */
    function setupPipeline() {
      var deps = bundler.pipeline.get('deps');
      deps.push(getCache(deps._streams[0].cache));
    }
  }
}