Register plugin in Spyder's main window
185537
def register_plugin(self):
        """"""
        self.profiler.datatree.sig_edit_goto.connect(self.main.editor.load)
        self.profiler.redirect_stdio.connect(
            self.main.redirect_internalshell_stdio)
        self.main.add_dockwidget(self)

        profiler_act = create_action(self, _("Profile"),
                                     icon=self.get_plugin_icon(),
                                     triggered=self.run_profiler)
        profiler_act.setEnabled(is_profiler_installed())
        self.register_shortcut(profiler_act, context="Profiler",
                               name="Run profiler")
        
        self.main.run_menu_actions += [profiler_act]
        self.main.editor.pythonfile_dependent_actions += [profiler_act]
132588
function plugin(analytics) {
  analytics.spies = [];

  /**
   * Spy on a `method` of host `object`.
   *
   * @param {Object} object
   * @param {string} method
   * @return {Analytics}
   */
  analytics.spy = function(object, method) {
    var s = spy(object, method);
    this.spies.push(s);
    return this;
  };

  /**
   * Stub a `method` of host `object`.
   *
   * @param {Object} object
   * @param {string} method
   * @param {Function} fn A function to be called in place of the stubbed method.
   * @return {Analytics}
   */
  analytics.stub = function(object, method, fn) {
    var s = stub(object, method, fn);
    this.spies.push(s);
    return this;
  };

  /**
   * Restore all spies.
   *
   * @return {Analytics}
   */
  analytics.restore = function() {
    each(function(spy) {
      spy.restore();
    }, this.spies);
    this.spies = [];
    return this;
  };

  /**
   * Assert that a `spy` was called with `args...`
   *
   * @param {Spy} spy
   * @param {*} [args...]
   * @return {Analytics}
   */
  analytics.called = function(spy) {
    assert(
      contains(spy, this.spies),
      'You must call `.spy(object, method)` prior to calling `.called()`.'
    );
    assert(spy.called, fmt('Expected "%s" to have been called.', spy.name));

    var args = Array.prototype.slice.call(arguments, 1);
    if (!args.length) return this;

    assert(
      spy.got.apply(spy, args),
      fmt(
        'Expected "%s" to be called with "%s", \n but it was called with "%s".',
        spy.name,
        JSON.stringify(args, null, 2),
        JSON.stringify(spy.args[0], null, 2)
      )
    );

    return this;
  };

  /**
   * Assert that a `spy` was not called with `args...`.
   *
   * @param {Spy} spy
   * @param {*} [args...]
   * @return {Analytics}
   */
  analytics.didNotCall = function(spy) {
    assert(
      contains(spy, this.spies),
      'You must call `.spy(object, method)` prior to calling `.didNotCall()`.'
    );

    var args = Array.prototype.slice.call(arguments, 1);
    if (!args.length) {
      assert(
        !spy.called,
        fmt('Expected "%s" not to have been called.', spy.name)
      );
    } else {
      assert(
        !spy.got.apply(spy, args),
        fmt('Expected "%s" not to be called with "%o", but it was called with "%o".', spy.name, args, spy.args[0])
      );
    }

    return this;
  };

  /**
   * Assert that a `spy` was not called 1 time.
   *
   * @param {Spy} spy
   * @return {Analytics}
   */
  analytics.calledOnce = calledTimes(1);

  /**
   * Assert that a `spy` was called 2 times.
   *
   * @param {Spy} spy
   * @return {Analytics}
   */
  analytics.calledTwice = calledTimes(2);

  /**
   * Assert that a `spy` was called 3 times.
   *
   * @param {Spy} spy
   * @return {Analytics}
   */
  analytics.calledThrice = calledTimes(3);

  /**
   * Generate a function for asserting a spy
   * was called `n` times.
   *
   * @param {number} n
   * @return {Function}
   */
  function calledTimes(n) {
    return function(spy) {
      var callCount = spy.args.length;
      assert(
        n === callCount,
        fmt(
          'Expected "%s" to have been called %s time%s, but it was only called %s time%s.',
          spy.name,
          n,
          n !== 1 ? 's' : '',
          callCount,
          callCount !== 1 ? 's' : ''
        )
      );
    };
  }

  /**
   * Assert that a `spy` returned `value`.
   *
   * @param {Spy} spy
   * @param {*} value
   * @return {Tester}
   */
  analytics.returned = function(spy, value) {
    assert(
      contains(spy, this.spies),
      'You must call `.spy(object, method)` prior to calling `.returned()`.'
    );
    assert(
      spy.returned(value),
      fmt('Expected "%s" to have returned "%o".', spy.name, value)
    );

    return this;
  };

  /**
   * Assert that a `spy` did not return `value`.
   *
   * @param {Spy} spy
   * @param {*} value
   * @return {Tester}
   */
  analytics.didNotReturn = function(spy, value) {
    assert(
      contains(spy, this.spies),
      'You must call `.spy(object, method)` prior to calling `.didNotReturn()`.'
    );
    assert(
      !spy.returned(value),
      fmt('Expected "%s" not to have returned "%o".', spy.name, value)
    );

    return this;
  };

  /**
   * Call `reset` on the integration.
   *
   * @return {Analytics}
   */
  analytics.reset = function() {
    this.user().reset();
    this.group().reset();
    return this;
  };

  /**
   * Compare `int` against `test`.
   *
   * To double-check that they have the right defaults, globals, and config.
   *
   * @param {Function} A actual integration constructor
   * @param {Function} B test integration constructor
   */
  analytics.compare = function(A, B) {
    var a = new A();
    var b = new B();
    // name
    assert(
      a.name === b.name,
      fmt('Expected name to be "%s", but it was "%s".', b.name, a.name)
    );

    // options
    var aDefaults = a.defaults;
    var bDefaults = b.defaults;
    // TODO(ndhoule): Confirm this can be an `each` call and convert it
    // eslint-disable-next-line guard-for-in
    for (var key in bDefaults) {
      assert(
        aDefaults.hasOwnProperty(key),
        fmt('The integration does not have an option named "%s".', key)
      );
      assert.deepEqual(
        aDefaults[key], bDefaults[key],
        fmt(
          'Expected option "%s" to default to "%s", but it defaults to "%s".',
          key, bDefaults[key], aDefaults[key]
        )
      );
    }

    // globals
    var aGlobals = a.globals;
    var bGlobals = b.globals;
    each(function(key) {
      assert(
        contains(key, aGlobals),
        fmt('Expected global "%s" to be registered.', key)
      );
    }, bGlobals);

    // assumesPageview
    assert(
      a._assumesPageview === b._assumesPageview,
      'Expected the integration to assume a pageview.'
    );

    // readyOnInitialize
    assert(
      a._readyOnInitialize === b._readyOnInitialize,
      'Expected the integration to be ready on initialize.'
    );

    // readyOnLoad
    assert(
      a._readyOnLoad === b._readyOnLoad,
      'Expected integration to be ready on load.'
    );
  };

  /**
   * Assert the integration being tested loads.
   *
   * @param {Integration} integration
   * @param {Function} done
   */
  analytics.load = function(integration, done) {
    analytics.assert(!integration.loaded(), 'Expected `integration.loaded()` to be false before loading.');
    analytics.once('ready', function() {
      analytics.assert(integration.loaded(), 'Expected `integration.loaded()` to be true after loading.');
      done();
    });
    analytics.initialize();
    analytics.page({}, { Marketo: true });
  };

  /**
   * Assert a script, image, or iframe was loaded.
   *
   * @param {string} str DOM template
   */

  analytics.loaded = function(integration, str) {
    if (typeof integration === 'string') {
      str = integration;
      integration = this.integration();
    }

    var tags = [];

    assert(
      contains(integration.load, this.spies),
      'You must call `.spy(integration, \'load\')` prior to calling `.loaded()`.'
    );

    // collect all Image or HTMLElement objects
    // in an array of stringified elements, for human-readable assertions.
    each(function(el) {
      var tag = {};
      if (el instanceof HTMLImageElement) {
        tag.type = 'img';
        tag.attrs = { src: el.src };
      } else if (type(el) === 'element') {
        tag.type = el.tagName.toLowerCase();
        tag.attrs = stripAttrs(tag.type, attributes(el));
      }
      if (tag.type) tags.push(stringify(tag.type, tag.attrs));
    }, integration.load.returns);

    // normalize formatting
    var tag = objectify(str);

    // strip unwanted attrs we do not control before we assert
    tag.attrs = stripAttrs(tag.type, tag.attrs);

    var expected = stringify(tag.type, tag.attrs);

    if (!tags.length) {
      assert(false, fmt('No tags were returned.\nExpected %s.', expected));
    } else {
      // show the closest match
      assert(
        contains(expected, tags),
        fmt('\nExpected %s.\nFound %s', expected, tags.join('\n'))
      );
    }
  };

  /**
   * Remove unwanted script/iframe attrs
   *
   * @param {String} tagType
   * @param {Object} attrs
   * @return {Object} ret
   */

  function stripAttrs(tagType, attrs) {
    var ret = extend({}, attrs);

    switch (tagType) {
    case 'script':
      // don't care about these properties.
      delete ret.type;
      delete ret.async;
      delete ret.defer;
      break;
    case 'iframe':
      // don't care about these properties.
      delete ret.width;
      delete ret.height;
      delete ret.style;
      delete ret.scrolling;
      delete ret.frameBorder;
      break;
    default:
      // no default case
    }

    return ret;
  }

  /**
   * Get current integration.
   *
   * @return {Integration}
   */
  analytics.integration = function() {
    // TODO(ndhoule): Confirm this can be an `each` call and convert it
    // eslint-disable-next-line guard-for-in
    for (var name in this._integrations) {
      return this._integrations[name];
    }
  };

  /**
   * Assert a `value` is truthy.
   *
   * @param {*} value
   * @return {Tester}
   */
  analytics.assert = assert;

  /**
   * Wait for script elements to finish loading to avoid errors if they load
   * after a reset.
   *
   * @param {Function} callback
   */
  analytics.waitForScripts = waitForScripts;

  /**
   * Expose all of the methods on `assert`.
   *
   * @param {*} args...
   * @return {Tester}
   */
  each(function(key) {
    analytics[key] = function() {
      var args = Array.prototype.slice.call(arguments);
      assert[key].apply(assert, args);
      return this;
    };
  }, keys(assert));

  /**
   * Create a DOM node string.
   */
  function stringify(name, attrs) {
    var str = [];
    str.push('<' + name);
    each(function(val, key) {
      str.push(' ' + key + '="' + val + '"');
    }, attrs);
    str.push('>');
    // block
    if (name !== 'img') {
      str.push('</' + name + '>');
    }
    return str.join('');
  }

  /**
   * DOM node attributes as object.
   *
   * @param {Element}
   * @return {Object}
   */
  function attributes(node) {
    var obj = {};
    each(function(attr) {
      obj[attr.name] = attr.value;
    }, node.attributes);
    return obj;
  }

  /**
   * Given a string, give back DOM attributes.
   *
   * @param {string} str
   * @return {Object}
   */
  function objectify(str) {
    // replace `src` with `data-src` to prevent image loading
    str = str.replace(' src="', ' data-src="');

    var el = domify(str);
    var attrs = {};

    each(function(attr) {
      // then replace it back
      var name = attr.name === 'data-src' ? 'src' : attr.name;
      attrs[name] = attr.value;
    }, el.attributes);

    return {
      type: el.tagName.toLowerCase(),
      attrs: attrs
    };
  }
}
405322
def register_plugin_module(mod):
    """"""
    for k, v in load_plugins_from_module(mod).items():
        if k:
            if isinstance(k, (list, tuple)):
                k = k[0]
            global_registry[k] = v
780711
def register_plugin(type, klass)
      type = type.to_s
      @plugins[type] ||= []
      @plugins[type].push(klass) unless @plugins[type].include?(klass)
    end
558384
def patch_spyder2(verbose=False):
    ''' '''
    try:
        # patch spyderlib/config.py for file extension
        from spyderlib import config
        src_file = config.__file__
        spyderlib_dir = os.path.dirname(src_file)
        if verbose:
            print('Patching {}'.format(src_file))
        with open(src_file, encoding='utf-8') as src:
            content = src.read()
        with open(src_file, 'w', encoding='utf-8') as src:
            src.write(content.replace('''
    (_("Cython/Pyrex files"), ('.pyx', '.pxd', '.pxi')),
    (_("C files"), ('.c', '.h')),''', '''
    (_("Cython/Pyrex files"), ('.pyx', '.pxd', '.pxi')),
    (_("SoS files"), ('.sos', )),
    (_("C files"), ('.c', '.h')),'''))
        #
        # patch spyderlib/cli_options.py to add command line option --kernel
        src_file = os.path.join(spyderlib_dir, 'cli_options.py')
        if verbose:
            print('Patching {}'.format(src_file))
        with open(src_file, encoding='utf-8') as src:
            content = src.read()
        with open(src_file, 'w', encoding='utf-8') as src:
            src.write(content.replace('''with Python profiling)")
    options, args = parser.parse_args()''',
            '''with Python profiling)")
    parser.add_option('--kernel', help="Jupyter kernel to start.")
    options, args = parser.parse_args()'''))
        #
        # patch spyderlib.utils.sourcecode.py,
        src_file = os.path.join(spyderlib_dir, 'utils', 'sourcecode.py')
        if verbose:
            print('Patching {}'.format(src_file))
        with open(src_file, encoding='utf-8') as src:
            content = src.read()
        with open(src_file, 'w', encoding='utf-8') as src:
            src.write(content.replace(
                "'Python': ('py', 'pyw', 'python', 'ipy')",
                "'Python': ('py', 'pyw', 'python', 'ipy', 'sos')")
                .replace(
                '''CELL_LANGUAGES = {'Python': ('#%%', '# %%', '# <codecell>', '# In[')}''',
                '''CELL_LANGUAGES = {'Python': ('#%%', '# %%', '# <codecell>', '# In[', '%cell')}''')
            )
        #
        # patch spyderlib/spyder.py
        src_file = os.path.join(spyderlib_dir, 'spyder.py')
        if verbose:
            print('Patching {}'.format(src_file))
        with open(src_file, encoding='utf-8') as src:
            content = src.read()
        with open(src_file, 'w', encoding='utf-8') as src:
            src.write(content.replace(
            '''
    app.exec_()
''',
            r'''
    try:
        if options.kernel == 'sos':
            cfg_file = os.path.expanduser('~/.ipython/profile_default/ipython_config.py')
            has_cfg = os.path.isfile(cfg_file)
            if has_cfg and not os.path.isfile(cfg_file + '.sos_bak'):
                os.rename(cfg_file, cfg_file + '.sos_bak')
            with open(cfg_file, 'w') as cfg:
                cfg.write("c.IPKernelApp.kernel_class =  'sos_notebook.kernel.SoS_Kernel'\n")
        app.exec_()
    finally:
        if options.kernel == 'sos':
            os.remove(cfg_file)
            if os.path.isfile(cfg_file + '.sos_bak'):
                os.rename(cfg_file + '.sos_bak', cfg_file)
'''))
        #
        print('\nSpyder is successfully patched to accept .sos format and sos kernel.')
        print('Use ')
        print()
        print('    $ spyder --kernel sos')
        print()
        print('to start spyder with sos kernel')
    except Exception as e:
        sys.exit('Failed to patch spyder: {}'.format(e))
319260
function registerPlugin(type, Plugin) {
    if (!plugins[type]) {
      throw new Error('Attempting to register "' + Plugin + '" as "' + type + '" which is not a valid HTMLBars plugin type.');
    }

    plugins[type].push(Plugin);
  }
64559
def initialize_plugin_in_mainwindow_layout(self):
        
        if self.get_option('first_time', True):
            try:
                self.on_first_registration()
            except NotImplementedError:
                return
            self.set_option('first_time', False)
442973
def register_plugin(self):
        """"""
        ipyconsole = self.main.ipyconsole
        treewidget = self.fileexplorer.treewidget

        self.main.add_dockwidget(self)
        self.fileexplorer.sig_open_file.connect(self.main.open_file)
        self.register_widget_shortcuts(treewidget)

        treewidget.sig_edit.connect(self.main.editor.load)
        treewidget.sig_removed.connect(self.main.editor.removed)
        treewidget.sig_removed_tree.connect(self.main.editor.removed_tree)
        treewidget.sig_renamed.connect(self.main.editor.renamed)
        treewidget.sig_renamed_tree.connect(self.main.editor.renamed_tree)
        treewidget.sig_create_module.connect(self.main.editor.new)
        treewidget.sig_new_file.connect(lambda t: self.main.editor.new(text=t))
        treewidget.sig_open_interpreter.connect(
            ipyconsole.create_client_from_path)
        treewidget.redirect_stdio.connect(
            self.main.redirect_internalshell_stdio)
        treewidget.sig_run.connect(
            lambda fname:
            ipyconsole.run_script(fname, osp.dirname(fname), '', False, False,
                                  False, True))
        treewidget.sig_open_dir.connect(
            lambda dirname:
            self.main.workingdirectory.chdir(dirname,
                                             refresh_explorer=False,
                                             refresh_console=True))

        self.main.editor.open_dir.connect(self.chdir)

        # Signal "set_explorer_cwd(QString)" will refresh only the
        # contents of path passed by the signal in explorer:
        self.main.workingdirectory.set_explorer_cwd.connect(
                     lambda directory: self.refresh_plugin(new_path=directory,
                                                           force_current=True))
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)
194868
def register_plugin(self, plugin):
        
        if hasattr(plugin, 'initialise'):
            plugin.initialise()
        if self.valid_api_plugin(plugin):
            log.debug("Registering API plugin: {}".format(plugin))
            self._api_plugins[plugin.request] = plugin()
        elif self.valid_debugger_plugin(plugin):
            log.debug("Registering debugger plugin: {}".format(plugin))
            self._debugger_plugins[plugin.host] = plugin()
        elif self.valid_view_plugin(plugin):
            log.debug("Registering view plugin: {}".format(plugin))
            self._view_plugins[plugin.name] = plugin()
        elif self.valid_web_plugin(plugin):
            log.debug("Registering web plugin: {}".format(plugin))
            self._web_plugins[plugin.name] = plugin()
        elif self.valid_command_plugin(plugin):
            log.debug("Registering command plugin: {}".format(plugin))
            self._command_plugins[plugin.name] = plugin()
            if voltron.debugger:
                voltron.debugger.register_command_plugin(plugin.name, plugin.command_class)
        else:
            log.debug("Ignoring invalid plugin: {}".format(plugin))
560240
function main(browserify, options) {
	options = adjustOptions(options);
	options = defaultOptions(browserify, options);

	return browserify
		.plugin(watchAdditional, options)
		.plugin(flexiRequire, options);
}
638168
def RegisterBuiltin(cls, arg):
        '''
        '''
        if arg in cls.types_dict:
            raise RuntimeError, '%s already registered' %arg
        class _Wrapper(arg):
            'Wrapper for builtin %s\n%s' %(arg, cls.__doc__)
        _Wrapper.__name__ = '_%sWrapper' %arg.__name__
        cls.types_dict[arg] = _Wrapper
716889
def initialize_plugin(self):
        
        self.create_toggle_view_action()

        self.plugin_actions = self.get_plugin_actions() + [MENU_SEPARATOR,
                                                           self.undock_action]
        add_actions(self.options_menu, self.plugin_actions)
        self.options_button.setMenu(self.options_menu)
        self.options_menu.aboutToShow.connect(self.refresh_actions)

        self.sig_show_message.connect(self.show_message)
        self.sig_update_plugin_title.connect(self.update_plugin_title)
        self.sig_option_changed.connect(self.set_option)
        self.setWindowTitle(self.get_plugin_title())
786161
def register_plugin(name, &block)
      plugin = Plugin.new
      plugin.instance_eval(&block)
      @plugins[name] = plugin
    end
838071
def register(self, callback, name):
        ''
        server.CALLBACKS[name] = callback
        self.run('''
            window.skink.%s = function(args=[]) {
                window.skink.call("%s", args);
            }''' % (name, name))
2778
def registerAddon(cls, name, addon, force=False):
        
        prop = '_{0}__addons'.format(cls.__name__)
        cmds = getattr(cls, prop, {})

        if name in cmds and not force:
            raise errors.AddonAlreadyExists(cls, name, addon)

        cmds[name] = addon
        try:
            if issubclass(addon, cls):
                setattr(addon, '_{0}__addonName'.format(addon.__name__), name)
        except StandardError:
            pass

        setattr(cls, prop, cmds)
1178475
function SwRegisterPlugin(options = {}) {
    let filePath = path.resolve(cwd, (options.filePath || './src/sw-register.js'));

    if (!fs.existsSync(filePath)) {
        filePath = path.resolve(__dirname, 'templates', 'sw-register.js');
    }
    this.filePath = filePath;
    this.fileName = options.output || path.basename(filePath);
    this.version = options.version || getVersion();
    this.prefix = options.prefix;
    this.excludes = options.excludes || [];
    this.includes = options.includes || [];
    this.scope = options.scope || '/';
    this.entries = options.entries || [];
    this.entriesInfo = {};
}