Copy or link a plugin from plugin_dir to plugins_dir/plugin_id.
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;
}
505765
def load_cli_plugins(cli, config_dir=None):
    """"""
    from .config import load_master_config

    config = load_master_config(config_dir=config_dir)
    plugins = discover_plugins(config.Plugins.dirs)

    for plugin in plugins:
        if not hasattr(plugin, 'attach_to_cli'):  # pragma: no cover
            continue
        logger.debug("Attach plugin `%s` to CLI.", _fullname(plugin))
        # NOTE: plugin is a class, so we need to instantiate it.
        try:
            plugin().attach_to_cli(cli)
        except Exception as e:  # pragma: no cover
            logger.error("Error when loading plugin `%s`: %s", plugin, e)
73212
def recursive_hardlink_dirs(source_d, destination_d):
    '''
    
    '''
    func = os.link
    if os.name == 'nt':
        func = shutil.copy
    if os.path.exists(destination_d):
        os.rmdir(destination_d)
    shutil.copytree(source_d, destination_d, copy_function=func)
1248965
function copyFile (src, done) {
        var dest = path.join(outdir, path.relative(compiler.dirname, src))
        var dirname = utils.dirname(dest)

        if (dirname === dest) {
          copy(src, dest, compiler.dirname, done)
        } else {
          mkdirp(dirname, function (err) {
            if (err) return done(err)
            copy(src, dest, compiler.dirname, done)
          })
        }
      }
495992
def _copy_across(self, rel_path, cb=None):
        """"""

        from . import copy_file_or_flo

        if not self.upstream.has(rel_path):

            if not self.alternate.has(rel_path):

                return None

            source = self.alternate.get_stream(rel_path)

            sink = self.upstream.put_stream(rel_path, metadata=source.meta)

            try:
                copy_file_or_flo(source, sink, cb=cb)
            except:
                self.upstream.remove(rel_path, propagate=True)
                raise

            source.close()
            sink.close()
1254271
function copyResources(output, plugin) {
    var logger = output.getLogger();

    var options    = output.getOptions();
    var outputRoot = options.get('root');

    var state = output.getState();
    var resources = state.getResources();

    var pluginRoot      = plugin.getPath();
    var pluginResources = resources.get(plugin.getName());

    var assetsFolder = pluginResources.get('assets');
    var assetOutputFolder = path.join(outputRoot, 'gitbook', plugin.getNpmID());

    if (!assetsFolder) {
        return Promise();
    }

    // Resolve assets folder
    assetsFolder = path.resolve(pluginRoot, assetsFolder);
    if (!fs.existsSync(assetsFolder)) {
        logger.warn.ln('assets folder for plugin "' + plugin.getName() + '" doesn\'t exist');
        return Promise();
    }

    logger.debug.ln('copy resources from plugin', assetsFolder);

    return fs.copyDir(
        assetsFolder,
        assetOutputFolder,
        {
            deleteFirst: false,
            overwrite: true,
            confirm: true
        }
    );
}
1350964
def get_plugins_from_dir(dir_path, classbase):
    """"""

    if dir_path == "sys":
        dir_path = os.path.abspath(
            os.path.join(os.path.dirname(__file__), 'plugins'))
        dir_plugins = get_plugins(dir_path)
        return {"dir": dir_path, "plugins": dir_plugins, "class": classbase}

    if dir_path == ".":
        dir_path = os.path.expanduser(
            os.path.expandvars(os.path.join(os.getcwd(), 'plugins')))
        dir_plugins = get_plugins(dir_path)
        return {"dir": dir_path, "plugins": dir_plugins, "class": classbase}
    else:

        dir_path = os.path.expanduser(os.path.expandvars(dir_path))
        prefix = "{0}/{1}".format(dir_path, classbase)

        user_path = "{0}/plugins".format(prefix)

        create_dir(user_path)
        create_file("{0}/__init__.py".format(prefix))
        create_file("{0}/plugins/__init__.py".format(prefix))
        sys.path.append(os.path.expanduser(dir_path))
        dir_plugins = get_plugins(user_path)
        # pprint({"dir": dir_path, "plugins": dir_plugins, "class": classbase})
        return {"dir": dir_path, "plugins": dir_plugins, "class": classbase}
158707
private void overrideAndRegisterPlugin(File sourceFile) {
    File destDir = fs.getInstalledPluginsDir();
    File destFile = new File(destDir, sourceFile.getName());
    if (destFile.exists()) {
      // plugin with same filename already installed
      deleteQuietly(destFile);
    }

    try {
      moveFile(sourceFile, destFile);

    } catch (IOException e) {
      throw new IllegalStateException(format("Fail to move plugin: %s to %s",
        sourceFile.getAbsolutePath(), destFile.getAbsolutePath()), e);
    }

    PluginInfo info = PluginInfo.create(destFile);
    PluginInfo existing = pluginInfosByKeys.put(info.getKey(), info);
    if (existing != null) {
      if (!existing.getNonNullJarFile().getName().equals(destFile.getName())) {
        deleteQuietly(existing.getNonNullJarFile());
      }
      LOG.info("Plugin {} [{}] updated to version {}", info.getName(), info.getKey(), info.getVersion());
    } else {
      LOG.info("Plugin {} [{}] installed", info.getName(), info.getKey());
    }
  }
1118713
def get_plugins(directory):
    
    # not just plugin_*.py
    plugins = []
    files = glob.glob(directory + "/*.py")
    for p in files:
        p = p.replace(directory + "/", "").replace(".py", "")
        if not p.startswith('_'):
            plugins.append(p)
    # log.info("Loading Plugins from {0}".format(dir))
    # log.info("   {0}".format(str(plugins)))
    return plugins
783819
protected void copyBundledPlugin(URL src, String fileName) throws IOException {
        LOGGER.log(FINE, "Copying {0}", src);
        fileName = fileName.replace(".hpi",".jpi"); // normalize fileNames to have the correct suffix
        String legacyName = fileName.replace(".jpi",".hpi");
        long lastModified = getModificationDate(src);
        File file = new File(rootDir, fileName);

        // normalization first, if the old file exists.
        rename(new File(rootDir,legacyName),file);

        // update file if:
        //  - no file exists today
        //  - bundled version and current version differs (by timestamp).
        if (!file.exists() || file.lastModified() != lastModified) {
            FileUtils.copyURLToFile(src, file);
            file.setLastModified(getModificationDate(src));
            // lastModified is set for two reasons:
            // - to avoid unpacking as much as possible, but still do it on both upgrade and downgrade
            // - to make sure the value is not changed after each restart, so we can avoid
            // unpacking the plugin itself in ClassicPluginStrategy.explode
        }

        // Plugin pinning has been deprecated.
        // See https://groups.google.com/d/msg/jenkinsci-dev/kRobm-cxFw8/6V66uhibAwAJ
    }
419720
function runPluginWithIdentifier (pluginName, identifier, options = {}) {
  const pluginFolderPath = options.dir || pluginFolder();

  // Append `.sketchplugin` if not passed in with the plugin name
  if (!pluginName.endsWith('.sketchplugin')) {
    pluginName += '.sketchplugin';
  }
  const pluginPath = `${pluginFolderPath}/${pluginName}`;

  // Check if the plugin actually exists before running anything!
  const exists = fs.existsSync(pluginPath);
  invariant(
    exists,
    `Plugin '${pluginPath}' not found! Cannot run plugin command!`
  );

  let args = '';

  if (options.context) {
    args += `--context='${JSON.stringify(options.context)}' `;
  }

  sketchtoolExec(`run ${escape(pluginPath)} ${identifier} ${args}`);
}
1070396
def expand_dir(_dir, cwd=os.getcwd()):
    
    _dir = os.path.expanduser(os.path.expandvars(_dir))
    if not os.path.isabs(_dir):
        _dir = os.path.normpath(os.path.join(cwd, _dir))
    return _dir
1201041
def Attach(self, pid):
    """"""
    if self.inferior.is_running:
      answer = raw_input('Already attached to process ' +
                         str(self.inferior.pid) +
                         '. Detach? [y]/n ')
      if answer and answer != 'y' and answer != 'yes':
        return None
      self.Detach()
    # Whatever position we had before will not make any sense now
    for plugin in self.plugins:
      plugin.position = None
    self.inferior.Reinit(pid)
693514
def copy_doc(doc, dest)
      raise ArgumentError, "_id is required for copying" unless doc['_id']
      slug = escape_docid(doc['_id'])
      destination = if dest.respond_to?(:has_key?) && dest['_id'] && dest['_rev']
        "#{dest['_id']}?rev=#{dest['_rev']}"
      else
        dest
      end
      connection.copy "#{path}/#{slug}", destination
    end
332525
def copy_from(self, other):
        """"""
        self.verbose, self.quiet, self.path, self.name, self.tracing = other.verbose, other.quiet, other.path, other.name, other.tracing
145109
def link_in(self, other, preserve=False):
        
        if preserve:
            other = other.clone()
        link_modules(self, other)
1339823
function possiblyFetch(id, plugins_dir, options) {
    var parsedSpec = pluginSpec.parse(id);
    //Check if a mapping exists for the plugin id
    //if it does, convert id to new name id
    var newId = parsedSpec.scope ? null : pluginMapper.oldToNew[parsedSpec.id];
    if(newId) {
        if(parsedSpec.version) {
            id = newId + '@' + parsedSpec.version;
        } else {
            id = newId;
        }
    }

    // if plugin is a relative path, check if it already exists
    var plugin_src_dir = isAbsolutePath(id) ? id : path.join(plugins_dir, parsedSpec.id);

    // Check that the plugin has already been fetched.
    if (fs.existsSync(plugin_src_dir)) {
        return Q(plugin_src_dir);
    }

    var alias =  parsedSpec.scope ? null : pluginMapper.newToOld[parsedSpec.id] || newId;
    // if the plugin alias has already been fetched, use it.
    if (alias && fs.existsSync(path.join(plugins_dir, alias))) {
        events.emit('warn', 'Plugin with alternate id ' + alias + ' is already fetched, so installing it instead of ' + parsedSpec.id);
        return Q(path.join(plugins_dir, alias));
    }

    // if plugin doesnt exist, use fetch to get it.
    if (newId) {
        events.emit('warn', 'Notice: ' + parsedSpec.id + ' has been automatically converted to ' + newId + ' and fetched from npm. This is due to our old plugins registry shutting down.');
    }
    var opts = underscore.extend({}, options, {
        client: 'plugman'
    });

    return plugman.raw.fetch(id, plugins_dir, opts);
}