Creates a plugin argument parser.

            `plugin_obj`
                ``Plugin`` object.

            Returns ``FocusArgParser`` object.
550207
def _get_plugin_parser(self, plugin_obj):
        

        prog_name = 'focus ' + plugin_obj.command
        desc = (plugin_obj.__doc__ or '').strip()

        parser = FocusArgParser(prog=prog_name, description=desc)
        plugin_obj.setup_parser(parser)

        return parser
1002416
function parser (inputs, output, plugins, cb) {
  var data = {
    charset: 'UTF-8',
    headers: DEFAULT_HEADERS,
    translations: {
      context: {}
    }
  }

  var defaultContext = data.translations.context

  var headers = data.headers
  headers['plural-forms'] = headers['plural-forms'] || DEFAULT_HEADERS['plural-forms']
  headers['content-type'] = headers['content-type'] || DEFAULT_HEADERS['content-type']

  var nplurals = /nplurals ?= ?(\d)/.exec(headers['plural-forms'])[1]

  inputs
    .forEach(function (file) {
      var resolvedFilePath = path.join(process.cwd(), file)
      var src = fs.readFileSync(resolvedFilePath, 'utf8')

      try {
        var ast = babelParser.parse(src, {
          sourceType: 'module',
          plugins: ['jsx'].concat(plugins)
        })
      } catch (e) {
        console.error(`SyntaxError in ${file} (line: ${e.loc.line}, column: ${e.loc.column})`)
        process.exit(1)
      }

      walk.simple(ast.program, {
        CallExpression: function (node) {
          if (functionNames.hasOwnProperty(node.callee.name) ||
            node.callee.property && functionNames.hasOwnProperty(node.callee.property.name)) {
            var functionName = functionNames[node.callee.name] || functionNames[node.callee.property.name]
            var translate = {}

            var args = node.arguments
            for (var i = 0, l = args.length; i < l; i++) {
              var name = functionName[i]

              if (name && name !== 'count' && name !== 'domain') {
                var arg = args[i]
                var value = arg.value

                if (value) {
                  var line = node.loc.start.line
                  translate[name] = value
                  translate['comments'] = {
                    reference: file + ':' + line
                  }
                }

                if (name === 'msgid_plural') {
                  translate.msgstr = []
                  for (var p = 0; p < nplurals; p++) {
                    translate.msgstr[p] = ''
                  }
                }
              }
            }

            var context = defaultContext
            var msgctxt = translate.msgctxt

            if (msgctxt) {
              data.translations[msgctxt] = data.translations[msgctxt] || {}
              context = data.translations[msgctxt]
            }

            context[translate.msgid] = translate
          }
        }
      })
    })

  fs.writeFile(output, gettextParser.po.compile(data), function (err) {
    if (err) {
      cb(err)
    }
    cb(null)
  })
}
145064
def create_argparser(self):
        
        if self.desc:
            if self.title:
                fulldesc = '%s\n\n%s' % (self.title, self.desc)
            else:
                fulldesc = self.desc
        else:
            fulldesc = self.title
        return self.ArgumentParser(command=self, prog=self.name,
                                   description=fulldesc)
377004
function pluginTarget(obj)
{
    obj.__plugins = {};

    /**
     * Adds a plugin to an object
     *
     * @param pluginName {string} The events that should be listed.
     * @param ctor {Object} ?? @alvin
     */
    obj.registerPlugin = function (pluginName, ctor)
    {
        obj.__plugins[pluginName] = ctor;
    };

    /**
     * Instantiates all the plugins of this object
     *
     */
    obj.prototype.initPlugins = function ()
    {
        this.plugins = this.plugins || {};

        for (var o in obj.__plugins)
        {
            this.plugins[o] = new (obj.__plugins[o])(this);
        }
    };

    /**
     * Removes all the plugins of this object
     *
     */
    obj.prototype.destroyPlugins = function ()
    {
        for (var o in this.plugins)
        {
            this.plugins[o].destroy();
            this.plugins[o] = null;
        }

        this.plugins = null;
    };
}
242415
def GetParserObjects(cls, parser_filter_expression=None):
    
    includes, excludes = cls._GetParserFilters(parser_filter_expression)

    parser_objects = {}
    for parser_name, parser_class in iter(cls._parser_classes.items()):
      # If there are no includes all parsers are included by default.
      if not includes and parser_name in excludes:
        continue

      if includes and parser_name not in includes:
        continue

      parser_object = parser_class()
      if parser_class.SupportsPlugins():
        plugin_includes = None
        if parser_name in includes:
          plugin_includes = includes[parser_name]

        parser_object.EnablePlugins(plugin_includes)

      parser_objects[parser_name] = parser_object

    return parser_objects
72643
def _make_argparser(self):
        """"""
        self.argparser = ShellArgumentParser(prog='')
        subparsers = self.argparser.add_subparsers()

        for name in self.get_names():
            if name.startswith('parser_'):
                parser = subparsers.add_parser(name[7:])
                parser.set_defaults(func=getattr(self, 'arg_' + name[7:]))
                getattr(self, name)(parser)

        self.argparser_completer = None

        try:
            import argcomplete
        except ImportError:
            pass
        else:
            os.environ.setdefault("_ARGCOMPLETE_COMP_WORDBREAKS", " \t\"'")
            self.argparser_completer = argcomplete.CompletionFinder(self.argparser)
1309278
def _call(callable_obj, arg_names, namespace):
    
    arguments = {arg_name: getattr(namespace, arg_name)
                 for arg_name in arg_names}
    return callable_obj(**arguments)
457430
def create_parser(self, subparsers):
        
        self.parser = subparsers.add_parser(self.name, help=self.help, parents=self.parents)
        self.add_arguments()
        self.parser.set_defaults(func=self.handle)
        return self.parser
277202
def parser(self):
        '''
        
        '''
        if not hasattr(self, '_parser'):
            self._parser = self._compile()
        return self._parser
1292083
def build_subcommands_parser(parser, module):
    
    mdefs = module.__dict__
    keys = list(mdefs.keys())
    keys.sort()
    subparsers = parser.add_subparsers(help='sub-command help')
    for command in keys:
        if command.startswith('pub_'):
            func = module.__dict__[command]
            parser = subparsers.add_parser(command[4:], help=func.__doc__)
            parser.set_defaults(func=func)
            argspec = inspect.getargspec(func)
            flags = len(argspec.args)
            if argspec.defaults:
                flags = len(argspec.args) - len(argspec.defaults)
            if flags >= 1:
                for arg in argspec.args[:flags - 1]:
                    parser.add_argument(arg)
                parser.add_argument(argspec.args[flags - 1], nargs='*')
            short_opts = set([])
            for idx, arg in enumerate(argspec.args[flags:]):
                arg = arg.replace('_', '-')
                short_opt = arg[0]
                if not (arg.startswith('no') or (short_opt in short_opts)):
                    opts = ['-%s' % short_opt, '--%s' % arg]
                else:
                    opts = ['--%s' % arg]
                short_opts |= set([short_opt])
                if isinstance(argspec.defaults[idx], list):
                    parser.add_argument(*opts, action='append')
                elif isinstance(argspec.defaults[idx], dict):
                    parser.add_argument(*opts, type=json.loads)
                elif argspec.defaults[idx] is False:
                    parser.add_argument(*opts, action='store_true')
                elif argspec.defaults[idx] is not None:
                    parser.add_argument(*opts, default=argspec.defaults[idx])
                else:
                    parser.add_argument(*opts)
523118
def parser(self):
        
        parser = argparse.ArgumentParser(description=self.description,
                                         epilog=self.epilog)
        parser.add_argument('--version',
                            action='version',
                            version=self.version)
        return self.add_to_parser(parser)
49474
def get_module_plugins(module, classobj):
    
    try:
        names = module.__all__
    except AttributeError:
        names = [x for x in vars(module) if not x.startswith('_')]
    for name in names:
        try:
            obj = getattr(module, name)
        except AttributeError:
            continue
        try:
            if issubclass(obj, classobj):
                yield obj
        except TypeError:
            continue
740620
function Plugin(option, args) {
    return this.each(function() {
      var $this = $(this);
      var data = $this.data('bs.maskedinput');
      var options = typeof option == 'object' && option;
      if (!data) {
        $this.data('bs.maskedinput', (data = new MaskedInput(this, options)));
      }
      if (typeof option == 'string') {
        data[option](args);
      }
    });
  }
1031476
def call_plugin(plugin, f, *args, **kwargs):
    """"""
    try:
        getattr(plugin, f)
    except AttributeError:
        return None
    if kwargs:
        getattr(plugin, f)(
            *args,
            **kwargs
        )
    else:
        return getattr(plugin, f)(
            *args
        )
476186
def load(description, add_arguments_cb = lambda x: None, postprocess_conf_cb = lambda x: None):
        

        argparser = ArgumentParser(
            description = description,
            prefix_chars = '-+'
        )

        argparser.add_argument(
            '--version',
            dest = 'PRINT_VERSION',
            action = 'store_true',
            help = 'Print version and exit'
        )

        add_arguments_cb(argparser)

        # set up plugin argument argparser
        plugin_argparser = argparser.add_argument_group('Plugins')

        plugins = {}
        def load_plugin_group(group):
            """Load all plugins from the given plugin_group."""
            for entry_point in iter_entry_points(group = group):
                name = str(entry_point).split(' =',1)[0]
                plugin = entry_point.load()
                if isclass(plugin) \
                    and not plugin in Conf.SUPPORTED_PLUGIN_INTERFACES \
                    and any([
                        issubclass(plugin, supported_plugin_interface)
                        for supported_plugin_interface in Conf.SUPPORTED_PLUGIN_INTERFACES
                    ]):

                    plugin_argparser.add_argument(
                        '+{}'.format(name),
                        dest = 'PLUGIN_{}'.format(name),
                        type = str,
                        nargs = '?',
                        default = DEFAULT,
                        metavar = 'args'.format(name),
                        help = make_argparse_help_safe(
                            call_plugin(
                                plugin,
                                'help'
                            )
                        )
                    )

                    # register plugin
                    plugins[name] = plugin
                else:
                    warning('Plugin not supported: {}'.format(name))

        load_plugin_group(Conf.PLUGIN_GROUP_BASE)
        if Conf.LOAD_PLUGINS:
            load_plugin_group(Conf.PLUGIN_GROUP)

        conf = vars(
            argparser.parse_args([
                v if i == 0 or v[0] == '+' or Conf.ARGS[i-1][0] != '+'
                else b32encode(v.encode()).decode()
                for i, v in enumerate(Conf.ARGS)
            ])
        )

        postprocess_conf_cb(conf)

        # apply configuration
        Conf.set(conf)

        if Conf.PRINT_VERSION:
            print(
                'pdml2flow version {}'.format(
                    Conf.VERSION
                ),
                file = Conf.OUT
            )
            sys.exit(0)

        # initialize plugins
        Conf.PLUGINS = []
        for conf_name, args in conf.items():
            if conf_name.startswith('PLUGIN_') and args != DEFAULT:
                plugin_name = conf_name[7:]
                Conf.PLUGINS.append(
                    # instantiate plugin
                    plugins[plugin_name](
                        *split(
                            b32decode(args.encode()).decode() if args is not None else ''
                        )
                    )
                )
730391
def takes_arg(obj, arg: str) -> bool:
    
    if inspect.isclass(obj):
        signature = inspect.signature(obj.__init__)
    elif inspect.ismethod(obj) or inspect.isfunction(obj):
        signature = inspect.signature(obj)
    else:
        raise ConfigurationError(f"object {obj} is not callable")
    return arg in signature.parameters
623334
def add_arguments(cls, parser, sys_arg_list=None):
        
        parser.add_argument('--multi_plugins',
                            dest='multi_plugins', required=True,
                            help="Column seperated list of health monitor "
                                 "plugins (only for 'multi' health monitor "
                                 "plugin)")

        arglist = ["multi_plugins"]

        # Read the list of the specified sub-plugins ahead of time, so we can
        # get their classes and add their parameters.
        sub_plugin_names_str = \
                utils.param_extract(sys_arg_list, None, "--multi_plugins")
        sub_plugin_classes = \
                cls.load_sub_plugins_from_str(sub_plugin_names_str).values()

        # Store the list of the sub-plugins in the class, so we can iterate
        # over those during parameter evaluation later on.
        cls.multi_plugin_classes = sub_plugin_classes

        # Now also add the parameters for the sub-plugins
        for pc in sub_plugin_classes:
            arglist.extend(pc.add_arguments(parser, sys_arg_list))

        return arglist