Determine if a composer package exists.

@param string $namespace Package namespace.
@param string $package   Package name.

@return bool
540399
public function packageExists($namespace, $package)
    {
        $folder = $this->vendorFolder . $namespace;
        $folderExists = file_exists($folder);

        if (!$folderExists) {
            return false;
        }

        $packageFolder = $folder . '/' . $package;
        $packageFolderExists = file_exists($packageFolder);

        return $packageFolderExists;
    }
879520
private function packageExists($slug, $package)
    {
        $path = Grav::instance()['locator']->findResource($package->package_type . '://' . $slug);
        Installer::isValidDestination($path);
        return Installer::lastErrorCode();
    }
117324
public function hasComposerPackage($vendor, $dev = false)
    {

        $packages = !$dev
            ? $this->composer->getRequire()
            : $this->composer->getRequireDev();

        return isset($packages[$vendor]);
    }
968599
public function isForPackage(PackageInterface $package)
    {
        if ($this->getForPackage() !== $package->getName()) {
            return false;
        }
        $fpv = $this->getForPackageVersion();
        if ($fpv !== null) {
            $pv = new Constraint('=', $package->getVersion());
            if (!$fpv->matches($pv)) {
                return false;
            }
        }

        return true;
    }
117751
private function allAreGlobal(array $namespaces): bool
    {
        foreach ($namespaces as $namespace) {
            if ($namespace->name && $namespace->name->toString() !== '') {
                return false;
            }
        }
        return true;
    }
529481
public function installPackage($package)
    {
        // We read its composer file
        $jsonData = $this->getPackageJsonFile($package);
        // We get the package assets dirs
        $packagesAssetsDir = $this->getPackageAssetsDirs($jsonData);
        if (!is_null($packagesAssetsDir)) {
            $this->log($package->getTarget(), self::LOG_INFO, self::CODE_INSTALLING_PACKAGE);
            $this->packagesStatuses[$package->getTarget()]['extra'] = 1;
            foreach ($packagesAssetsDir as $namespace => $packageAssetsDir) {
                if (!isset($this->packagesStatuses[$package->getTarget()]['dirs'])) {
                    $this->packagesStatuses[$package->getTarget()]['dirs'] = array();
                }
                $this->packagesStatuses[$package->getTarget()]['dirs'][$namespace] = null;
                // We install each package directory
                $this->installPackageDir($package, $namespace, $packageAssetsDir);
            }
        } else {
            $this->log($package->getTarget(), self::LOG_INFO, self::CODE_NO_INSTALL);
            $this->packagesStatuses[$package->getTarget()]['extra'] = 0;
        }
    }
1032486
public boolean packageExists(ModuleSymbol msym, Name fullname) {
        Assert.checkNonNull(msym);
        return lookupPackage(msym, fullname).exists();
    }
330777
public function package($package, $namespace = null, $path = null)
	{
		$namespace = $this->getPackageNamespace($package, $namespace);

		$path = $path ?: $this->guessPackagePath();

		//ChangeLog: Configuration setup removed


		// Next we will check for any "language" components. If language files exist
		// we will register them with this given package's namespace so that they
		// may be accessed using the translation facilities of the application.
		$lang = $path.'/lang';

		if ($this->app['files']->isDirectory($lang))
		{
			$this->app['translator']->addNamespace($namespace, $lang);
		}

		// Next, we will see if the application view folder contains a folder for the
		// package and namespace. If it does, we'll give that folder precedence on
		// the loader list for the views so the package views can be overridden.
		$appView = $this->getAppViewPath($package);

		if ($this->app['files']->isDirectory($appView))
		{
			$this->app['view']->addNamespace($namespace, $appView);
		}

		// Finally we will register the view namespace so that we can access each of
		// the views available in this package. We use a standard convention when
		// registering the paths to every package's views and other components.
		$view = $path.'/views';

		if ($this->app['files']->isDirectory($view))
		{
			$this->app['view']->addNamespace($namespace, $view);
		}
	}
533128
public function lookupPrefix( $namespace )
	{
		foreach ( $this->namespaces as $prefix => $value )
		{
			if ( strcasecmp( $namespace, $value ) === 0 ) return $prefix;
		}

		return false;
	}
334105
protected function publishAssets($package)
    {
        if (! $this->dispatcher->hasNamespace($package)) {
            return $this->error('Package does not exist.');
        }

        if ( ! is_null($path = $this->getPath())) {
            $this->publisher->publish($package, $path);
        } else {
            $path = $this->dispatcher->getPackagePath($package);

            $this->publisher->publishPackage($package, $path);
        }

        $this->output->writeln('<info>Assets published for package:</info> ' .$package);
    }
1075203
public static function isAsset(PackageInterface $package, array $configPackages = array())
    {
        $projectConfig = self::getProjectActivation($package, $configPackages);
        $enabled = false !== $projectConfig;

        return $enabled && (static::hasExtraActivation($package)
            || static::hasPluginDependency($package->getRequires())
            || static::hasPluginDependency($package->getDevRequires())
            || true === $projectConfig);
    }
1290647
public static function hasExtraActivation(PackageInterface $package)
    {
        $extra = $package->getExtra();

        return isset($extra['foxy']) && true === $extra['foxy'];
    }
1031122
def exists(package):
    
    pkg_config_exe = os.environ.get('PKG_CONFIG', None) or 'pkg-config'
    cmd = '{0} --exists {1}'.format(pkg_config_exe, package).split()
    return call(cmd) == 0
534657
protected function isLibrary(array $package) {
    // Add Swiftmailer support.
    if ($package['name'] == 'swiftmailer/swiftmailer') {
      $package['type'] = 'drupal-library';
    }

    $package_types = [
      'drupal-library',
      'bower-asset',
      'npm-asset',
    ];
    return (
      in_array($package['type'], $package_types) &&
      array_key_exists($package['name'], $this->rootPackage->getRequires())
    );
  }
80219
private function requireComposerPackage($package)
    {
        $composer = $this->findComposer();
        $process = new Process($composer.' require '.$package.''.$this->getDevOption(),
                       null, null, null, null);
        $this->output->writeln('<info>Running composer require '.$package.$this->getDevOption().'</info>');
        $process->run(function ($type, $line) {
            $this->output->write($line);
        });
    }
761224
public function package($package, $hint, $namespace = null)
	{
		$namespace = $this->getPackageNamespace($package, $namespace);

		$this->packages[] = $namespace;

		// First we will simply register the namespace with the repository so that it
		// can be loaded. Once we have done that we'll register an after namespace
		// callback so that we can cascade an application package configuration.
		$this->addNamespace($namespace, $hint);

		$this->afterLoading($namespace, function($me, $group, $items) use ($package)
		{
			$env = $me->getEnvironment();

			$loader = $me->getLoader();

			return $loader->cascadePackage($env, $package, $group, $items);
		});
	}
53837
public function hasPackage($package_name)
    {
        if (!isset($this->packages_instances[$package_name])) {
            try {
                $this->packages_instances[$package_name] = $this->_buildNewPackage($package_name);
            } catch (\Exception $e) {
            }
        }
        return isset($this->packages_instances[$package_name]);
    }