Validate a command plugin, ensuring it is a command plugin and has the
        necessary fields present.

        `plugin` is a subclass of scruffy's Plugin class.
8995
def valid_command_plugin(self, plugin):
        
        if (issubclass(plugin, CommandPlugin)   and
            hasattr(plugin, 'plugin_type')      and plugin.plugin_type == 'command' and
            hasattr(plugin, 'name')             and plugin.name != None):
            return True
        return False
226030
def add_plugin(self, f):
        
        if f.endswith('.py'):

            # Just the basename without extension
            plugin_name = os.path.splitext(os.path.basename(f))[0]

            # It's possible the plugin has been modified and needs to be reloaded
            if plugin_name in sys.modules:
                try:
                    handler = reload(sys.modules[plugin_name])
                    print'\t- %s %sRELOAD%s' % (plugin_name, color.Yellow, color.Normal)
                except ImportError, error:
                    print 'Failed to import plugin: %s (%s)' % (plugin_name, error)
                    return
            else:
                # Not already loaded so try to import it
                try:
                    handler = __import__(plugin_name, globals(), locals(), [], -1)
                except ImportError, error:
                    print 'Failed to import plugin: %s (%s)' % (plugin_name, error)
                    return

            # Run the handler through plugin validation
            plugin = self.validate(handler)
            print '\t- %s %sOK%s' % (plugin_name, color.Green, color.Normal)
            if plugin:

                # Okay must be successfully loaded so capture the plugin meta-data,
                # modification time and register the plugin through the callback
                plugin['name'] = plugin_name
                plugin['dependencies'] = plugin['class'].dependencies
                plugin['docstring'] = plugin['class'].__doc__
                plugin['mod_time'] = datetime.utcfromtimestamp(os.path.getmtime(f))

                # Plugin may accept sample_sets as input
                try:
                    plugin['sample_set_input'] = getattr(plugin['class'], 'sample_set_input')
                except AttributeError:
                    plugin['sample_set_input'] = False

                # Now pass the plugin back to workbench
                self.plugin_callback(plugin)
562750
def load_plugin(self, p):
        
        if p.is_loaded():
            return
        # load required plugins first
        reqnames = p.required
        reqplugins = []
        for name in reqnames:
            try:
                reqplugins.append(self.__plugins[name])
            except KeyError as e:
                log.error("Required Plugin %s not found. Cannot load %s." % (name, p))
                raise errors.PluginInitError('Required Plugin %s not found. Cannot load %s. Reason: %s' % (name, p, e))
        for plug in reqplugins:
            try:
                self.load_plugin(plug)
            except errors.PluginInitError as e:
                log.error("Required Plugin %s could not be loaded. Cannot load %s" % (plug, p))
                raise errors.PluginInitError('Required Plugin %s could not be loaded. Cannot load %s. Reason: %s' % (plug,p, e))
        # load the actual plugin
        p._load()
        log.info('Initialized the plugin: %s' % p)
276745
public function validatePlugin($plugin)
    {
        if ($plugin instanceof DomainServiceInterface) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create domain service for %s; '
                . 'Domain service must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            DomainServiceInterface::class
        ));
    }
797520
static PluginValidation validatePluginMeta(final PluginMeta pluginList, final File file) {
        PluginValidation.State state = PluginValidation.State.VALID;
        if (pluginList == null) {
            return PluginValidation.builder()
                                   .message("No metadata")
                                   .state(PluginValidation.State.INVALID)
                                   .build();
        }
        List<String> messages = new ArrayList<>();
        if (null == pluginList.getName()) {
            messages.add("'name' not found in metadata");
            state = PluginValidation.State.INVALID;
        }
        if (null == pluginList.getVersion()) {
            messages.add("'version' not found in metadata");
            state = PluginValidation.State.INVALID;
        }
        if (null == pluginList.getRundeckPluginVersion()) {
            messages.add("'rundeckPluginVersion' not found in metadata");
            state = PluginValidation.State.INVALID;
        } else if (!SUPPORTED_PLUGIN_VERSIONS.contains(pluginList.getRundeckPluginVersion())) {
            messages.add("'rundeckPluginVersion': \"" + pluginList.getRundeckPluginVersion() + "\" is not supported");
            state = PluginValidation.State.INVALID;
        }
        if(pluginList.getRundeckPluginVersion().equals(VERSION_2_0)) {
            List<String> validationErrors = new ArrayList<>();

            PluginValidation.State
                hostCompatState =
                PluginMetadataValidator.validateTargetHostCompatibility(
                    validationErrors,
                    pluginList.getTargetHostCompatibility()
                );
            PluginValidation.State
                versCompatState = PluginMetadataValidator.validateRundeckCompatibility(
                validationErrors,
                pluginList.getRundeckCompatibilityVersion()
            );

            messages.addAll(validationErrors);
            state = state.or(hostCompatState)
                         .or(versCompatState);

        }
        final List<ProviderDef> pluginDefs = pluginList.getPluginDefs();
        for (final ProviderDef pluginDef : pluginDefs) {
            try {
                validateProviderDef(pluginDef);
            } catch (PluginException e) {
                messages.add(e.getMessage());
                state = PluginValidation.State.INVALID;
            }
        }
        return PluginValidation.builder()
                               .state(state)
                               .messages(messages)
                               .build();
    }
212211
public function validatePlugin($plugin)
    {
        if ($plugin instanceof AbstractPlugin) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create jQuery plugin for %s; Plugin must be an instance of %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            AbstractPlugin::class
        ));
    }
489156
function _validateCommand(name, command) {
    if (!_.isString(command.description)) {
        throw new Error(sprintf('Command "%s" must have a description string', name));
    } else if (!_.isFunction(command.invoke)) {
        throw new Error(sprintf('Command "%s" must have an invoke function', name));
    }
}
153764
function (plugin) {
    if (Array.isArray(plugin)) {
      for (var i = 0; i < plugin.length; i++) this.use(plugin[i]);
    } else if (typeof plugin === 'function') {
      plugin(this);
    } else {
      throw new TypeError('plugin must be a Function or an Array of Functions')
    }
    return this
  }
236056
function validate(cmd, args, info) {
  info = info || {};
  var conf = info.conf || {}
    , authrequired = typeof conf.requirepass === 'string'
    , db = info.db
    , result;

  // handle quit command special case
  if(cmd === COMMANDS.QUIT) {
    // reply with an object that mimics succesful validation
    info.command = {
      cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
    return info;
  // validate command is known
  }else{
    info.command = validators.command(cmd, args, info);
  }

  // check args length (arity)
  info.command.arity = validators.arity(cmd, args, info);

  // handle authentication requests
  if(cmd === COMMANDS.AUTH) {
    info.conn.authenticated =
      validators.auth(cmd, args, info);
  // handle unauthenticated requests when auth is enabled
  }else if(authrequired && !info.conn.authenticated) {
    throw AuthRequired;
  }

  // check operation on the correct type of value
  // this validation extracts keys, looks up the values
  // to determine the type of the existing value
  // the val array (or null) is assigned to the command
  // info object so that calling code may re-use it and
  // save looking up keys and values again where necessary
  info.command.value = validators.type(cmd, args, info);

  return info;
}
7288
public function validatePlugin($plugin)
    {
        if ($plugin instanceof DispatchableInterface) {
            // we're okay
            return;
        }

        throw new Exception\InvalidControllerException(sprintf(
            'Controller of type %s is invalid; must implement Zend\Stdlib\DispatchableInterface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin))
        ));
    }
195593
def register(self, plugin):
        
        if plugin.name not in self._registered:
            logger.info('Registering plugin %s' % plugin.name)
            self._registered[plugin.name] = plugin
        else:
            logger.warn('Plugin %s already registered' % plugin.name)
780711
def register_plugin(type, klass)
      type = type.to_s
      @plugins[type] ||= []
      @plugins[type].push(klass) unless @plugins[type].include?(klass)
    end
1319908
def has_command(self, command):
        """"""
        for pbt in self._plugins.values():
            if pbt.command == command:
                return True
        return False
1160359
public function validatePlugin($plugin)
    {
        if ($this->isValidModuleOptions($plugin)) {
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            ModuleOptionsInterface::class
        ));
    }
1323234
public static function isBoldgridPlugin( $plugin ) {
		if( empty( $plugin ) ) {
			return false;
		}

		$pluginChecker = new \Boldgrid\Library\Library\Plugin\Checker();

		$plugins = \Boldgrid\Library\Library\Util\Plugin::getFiltered( $pluginChecker->getPluginPattern() );

		return array_key_exists( $plugin, $plugins );
	}
392146
def validate_pluginid(value):
    ''''''
    valid = string.ascii_letters + string.digits + '.'
    return all(c in valid for c in value)
52972
public function validatePlugin($plugin)
    {
        if ($plugin instanceof AbstractContainer) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create session container for %s; Session conatiner must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            AbstractContainer::class
        ));
    }