/*
Based on platform type and current Config, determine whether dependent binaries are in place. Otherwise, add them
to the list of things to download.
16470
private List<String> determineListOfDownloadsToProcess() {
        List<String> list = new ArrayList<>();

        if (!Config.getBoolConfigProperty(ConfigProperty.DOWNLOAD_DEPENDENCIES)) {
            return list;
        }

        // for IEDriver
        if (SystemUtils.IS_OS_WINDOWS
                && !checkForPresenceOf(ConfigProperty.SELENIUM_IEDRIVER_PATH,
                        SeLionConstants.WEBDRIVER_IE_DRIVER_PROPERTY, SeLionConstants.IE_DRIVER)) {
            Config.setConfigProperty(ConfigProperty.SELENIUM_IEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR
                    + SeLionConstants.IE_DRIVER);
            list.add("iedriver");
        }

        // for MicrosoftWebDriver
        if (SystemUtils.IS_OS_WINDOWS
                && !checkForPresenceOf(ConfigProperty.SELENIUM_EDGEDRIVER_PATH,
                        SeLionConstants.WEBDRIVER_EDGE_DRIVER_PROPERTY, SeLionConstants.EDGE_DRIVER)) {
            Config.setConfigProperty(ConfigProperty.SELENIUM_EDGEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR
                    + SeLionConstants.EDGE_DRIVER);
            list.add("edgedriver");
        }

        // for chromedriver
        if (!checkForPresenceOf(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH,
                SeLionConstants.WEBDRIVER_CHROME_DRIVER_PROPERTY, SeLionConstants.CHROME_DRIVER)) {
            Config.setConfigProperty(ConfigProperty.SELENIUM_CHROMEDRIVER_PATH, SeLionConstants.SELION_HOME_DIR
                    + SeLionConstants.CHROME_DRIVER);
            list.add("chromedriver");
        }

        // for phantomjs
        if (!checkForPresenceOf(ConfigProperty.SELENIUM_PHANTOMJS_PATH,
                SeLionConstants.WEBDRIVER_PHANTOMJS_DRIVER_PROPERTY, SeLionConstants.PHANTOMJS_DRIVER)) {
            Config.setConfigProperty(ConfigProperty.SELENIUM_PHANTOMJS_PATH, SeLionConstants.SELION_HOME_DIR
                    + SeLionConstants.PHANTOMJS_DRIVER);
            list.add("phantomjs");
        }

        // for GeckoDriver
        if (!checkForPresenceOf(ConfigProperty.SELENIUM_GECKODRIVER_PATH,
                SeLionConstants.WEBDRIVER_GECKO_DRIVER_PROPERTY, SeLionConstants.GECKO_DRIVER)) {
            Config.setConfigProperty(ConfigProperty.SELENIUM_GECKODRIVER_PATH, SeLionConstants.SELION_HOME_DIR
                    + SeLionConstants.GECKO_DRIVER);
            list.add("geckodriver");
        }

        return list;
    }
422486
private static boolean requiredByPlatformFeature(File baseDir, File testFile) {
        try {
            Map<String, ProvisioningFeatureDefinition> features = new Product(baseDir).getFeatureDefinitions();
            for (ProvisioningFeatureDefinition fd : features.values()) {
                if (fd.isKernel()) {
                    if (requiredByFile(fd, baseDir, testFile))
                        return true;
                }
            }
        } catch (Exception e) {
        }
        return false;
    }
429764
function (dependencies, extension) {
            if (dependencies) {
                for (var i = dependencies.length - 1; i >= 0; i--) {
                    this.addDependency(dependencies[i], extension);
                }
            }
        }
1117318
private void updateDependencies(Element configuration, boolean pAddJsr160Proxy) {
        List<Element> dependencyElements =
                XmlUtils.findElements("/configuration/jolokia/dependencies/dependency", configuration);
        addJsr160Dependencies(configuration,dependencyElements, pAddJsr160Proxy);

        List<Dependency> dependencies = new ArrayList<Dependency>();
        for (Element dependencyElement : dependencyElements) {
            dependencies.add(new Dependency(dependencyElement));
        }
        projectOperations.addDependencies(projectOperations.getFocusedModuleName(), dependencies);
	}
1287654
function checkAndDownloadBinary() {
  if (process.env.SKIP_SASS_BINARY_DOWNLOAD_FOR_CI) {
    console.log('Skipping downloading binaries on CI builds');
    return;
  }

  var cachedBinary = sass.getCachedBinary(),
    cachePath = sass.getBinaryCachePath(),
    binaryPath = sass.getBinaryPath();

  if (sass.hasBinary(binaryPath)) {
    console.log('node-sass build', 'Binary found at', binaryPath);
    return;
  }

  try {
    mkdir.sync(path.dirname(binaryPath));
  } catch (err) {
    console.error('Unable to save binary', path.dirname(binaryPath), ':', err);
    return;
  }

  if (cachedBinary) {
    console.log('Cached binary found at', cachedBinary);
    fs.createReadStream(cachedBinary).pipe(fs.createWriteStream(binaryPath));
    return;
  }

  download(sass.getBinaryUrl(), binaryPath, function(err) {
    if (err) {
      console.error(err);
      return;
    }

    console.log('Binary saved to', binaryPath);

    cachedBinary = path.join(cachePath, sass.getBinaryName());

    if (cachePath) {
      console.log('Caching binary to', cachedBinary);

      try {
        mkdir.sync(path.dirname(cachedBinary));
        fs.createReadStream(binaryPath)
          .pipe(fs.createWriteStream(cachedBinary))
          .on('error', function (err) {
            console.log('Failed to cache binary:', err);
          });
      } catch (err) {
        console.log('Failed to cache binary:', err);
      }
    }
  });
}
974978
public List<TypedDependency> typedDependencies(boolean includeExtras) {
    List<TypedDependency> deps = includeExtras ? allTypedDependencies
                                                       : typedDependencies;
    correctDependencies(deps);
    return deps;
  }
1261536
def needs(self):
        """"""
        result = []
        for dep in self.dependencies:
            module = dep.split(".")[0].lower()
            if module not in result:
                result.append(module)

        return result
875143
@Override
    protected boolean evaluateDependencies(final Dependency dependency, final Dependency nextDependency, final Set<Dependency> dependenciesToRemove) {
        if (hashesMatch(dependency, nextDependency)) {
            if (!containedInWar(dependency.getFilePath())
                    && !containedInWar(nextDependency.getFilePath())) {
                if (firstPathIsShortest(dependency.getFilePath(), nextDependency.getFilePath())) {
                    mergeDependencies(dependency, nextDependency, dependenciesToRemove);
                } else {
                    mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                    return true; //since we merged into the next dependency - skip forward to the next in mainIterator
                }
            }
        } else if (isShadedJar(dependency, nextDependency)) {
            if (dependency.getFileName().toLowerCase().endsWith("pom.xml")) {
                mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                nextDependency.removeRelatedDependencies(dependency);
                return true;
            } else {
                mergeDependencies(dependency, nextDependency, dependenciesToRemove);
                dependency.removeRelatedDependencies(nextDependency);
            }
        } else if (cpeIdentifiersMatch(dependency, nextDependency)
                && hasSameBasePath(dependency, nextDependency)
                && vulnerabilitiesMatch(dependency, nextDependency)
                && fileNameMatch(dependency, nextDependency)) {
            if (isCore(dependency, nextDependency)) {
                mergeDependencies(dependency, nextDependency, dependenciesToRemove);
            } else {
                mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                return true; //since we merged into the next dependency - skip forward to the next in mainIterator
            }
        } else if (ecoSystemIs(AbstractNpmAnalyzer.NPM_DEPENDENCY_ECOSYSTEM, dependency, nextDependency)
                && namesAreEqual(dependency, nextDependency)
                && npmVersionsMatch(dependency.getVersion(), nextDependency.getVersion())) {

            if (!dependency.isVirtual()) {
                DependencyMergingAnalyzer.mergeDependencies(dependency, nextDependency, dependenciesToRemove);
            } else {
                DependencyMergingAnalyzer.mergeDependencies(nextDependency, dependency, dependenciesToRemove);
                return true;
            }
        }
        return false;
    }
682694
def depends_on(self, dependency):
        
        packages = self.package_info()
        return [package for package in packages if dependency in package.get("requires", "")]
1097283
async function resolveDependencies(rootFolder) {
    const includeFile = path.join(rootFolder, constants.INCLUDE_FILE);
    const includeJson = fs.readJsonSync(includeFile, 'utf8');
    await recDependencies(includeJson.dependencies, true);
    return depencyList;
}
1230428
private void checkAndLoadDependentExtensions() {
        boolean changed = false;
        for (Entry<String, AddOnClassLoader> entry : new HashMap<>(addOnLoaders).entrySet()) {
            AddOn runningAddOn = aoc.getAddOn(entry.getKey());
            if (runningAddOn.getInstallationStatus() == AddOn.InstallationStatus.UNINSTALLATION_FAILED) {
                continue;
            }
            for (String extClassName : runningAddOn.getExtensionsWithDeps()) {
                if (!runningAddOn.isExtensionLoaded(extClassName)) {
                    AddOn.AddOnRunRequirements reqs = runningAddOn.calculateExtensionRunRequirements(
                            extClassName,
                            aoc.getInstalledAddOns());
                    ExtensionRunRequirements extReqs = reqs.getExtensionRequirements().get(0);
                    if (extReqs.isRunnable()) {
                        List<AddOnClassLoader> dependencies = new ArrayList<>(extReqs.getDependencies().size());
                        for (AddOn addOnDep : extReqs.getDependencies()) {
                            dependencies.add(addOnLoaders.get(addOnDep.getId()));
                        }
                        AddOnClassLoader extAddOnClassLoader = new AddOnClassLoader(
                                entry.getValue(),
                                dependencies,
                                runningAddOn.getExtensionAddOnClassnames(extClassName));
                        Extension ext = loadAddOnExtension(runningAddOn, extReqs.getClassname(), extAddOnClassLoader);
                        AddOnInstaller.installAddOnExtension(runningAddOn, ext);
                        runnableAddOns.get(runningAddOn).add(extReqs.getClassname());
                        changed = true;
                    }
                }
            }
        }

        if (changed) {
            saveAddOnsRunState(runnableAddOns);
        }
    }
1317310
function updateXCConfigs(configItems, platformPath){
        xcconfigs.forEach(function(fileName){
            updateXCConfig(platformPath, fileName, configItems);
        });
    }
904481
function downloadProjectCompilation(project, platform, outputDir) {
	return waitForCompletion(project)
	.then(() => {
		if (project.compilations[platform]) {
			if (project.compilations[platform].isReady()) {
				return downloadFile(project.compilations[platform].downloadLink,
					outputDir + "/" + project.name + "-" + platform + ".zip")
				.catch((error) => {
					console.error("Couldn't download " + platform + " compilation from project " + project.id + ".");
					console.trace(error);
					throw error;
				});
			} else if (project.compilations[platform].isErred()) {
				console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
					". The compilation failed.");
				throw new Error("Compilation failed");
			} else {
				console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
					". Status: " + project.compilations[platform].status + ".");
				throw new Error("Platform ignored");
			}
		} else {
			console.error("Couldn't download " + platform + " compilation from " + project.name + " project: " + project.id +
				". There was not a compilation issued for the platform.");
			throw new Error("No compilation available");
		}
	})
	.catch((error) => {
		console.trace(error);
		throw error;
	});
}
466239
def check_dependencies(dependencies, module):
    
    if type(dependencies) == str:
        dependencies = [dependencies]
    elif type(dependencies) != list:
        raise TypeError('dependencies argument must be of type list or string')

    for dependency in dependencies:
        if dependency not in settings.INSTALLED_APPS:
            raise DependencyError('%s depends on %s, which should be in settings.INSTALLED_APPS' % (module, dependency))
322176
def has_resolved_dependencies(self):
        """"""
        for dependency in self.dependencies:
            if dependency.state != Task.State.DONE:
                return False

        return True
40636
function (options, callback) {
        options = extend({}, DEPENDENCY_WRITE_DEFAULTS, options)
        var json = require(options.jsonUri)

        // the JSON DSL has the option to have "/foo" in <moduleNameLeft>
        after.reduce(json, createFoldersIntoFilesIterator(options.uri), 
            {}, runDependencyMapper)

        function runDependencyMapper(err, data) {
            if (err) {
                return callback(err)
            }
            after.map(data, mapToDependencies, callback)
        }

        function mapToDependencies(dependencies, moduleName, callback) {
            if (isFile.test(moduleName)) {
                // the JSON DSL has the option to have "/foo" or ["/foo"]
                // in <moduleNameRight>.
                after.map(dependencies, createConvertToProxyNameIterator({
                    moduleName: moduleName,
                    uri: options.uri
                }), callback)
            }
        }
    }
609138
function updateBinary (os = platform, arch = process.arch) {
  return new Promise((resolve, reject) => {
    if (platform === 'freebsd') return resolve(`
There are no static ffmpeg builds for FreeBSD currently available.
The module will try to use the system-wide installation.

Install it by running "pkg install ffmpeg" or via ports.
`)
    if (platform === 'openbsd') return resolve(`
There are no static ffmpeg builds for OpenBSD currently available.
The module will try to use the system-wide installation.

Install it by running "pkg_add ffmpeg" or via ports.
`) 
    const dir = `bin/${os}/${arch}`
    const bin = `${dir}/ffmpeg${os === 'win32' ? '.exe' : ''}`
    const dest = path.join(__dirname, bin)
    const fname = `${os}-${arch}.tar.bz2`
    const tmp = path.join(__dirname, 'bin', fname)
    try { fs.mkdirSync(path.join(__dirname, 'bin')) } catch(e) {}
    let bar

	// Cleanup directory
	fs.emptyDirSync('bin')

    // Get the latest version
    const req = request.get(`https://github.com/FocaBot/ffmpeg-downloader/raw/master/bin/${fname}`)
    req.on('error', e => reject(e)) // Handle errors
    .on('data', c => {
      bar = bar || new ProgressBar(`${fname} [:bar] :percent (ETA: :etas)`, {
        complete: '=',
        incomplete: ' ',
        width: 25,
        total: parseInt(req.response.headers['content-length'])
      })

      bar.tick(c.length)
    })
    .on('end', () => setTimeout(() => {
      bar.tick(bar.total - bar.curr)
      console.log('Decompressing...')
      decompress(tmp, path.join(__dirname, 'bin')).then(f => {
        fs.unlinkSync(tmp)
        // Try to get the version number
        // Skip this if not the same arch/os as what launched it
        if (os === platform && arch === process.arch) {
          execFile(dest, ['-version'], (error, stdout, stderr) => {
            if (error || stderr.length) return reject(error || stderr)
            resolve(stdout)
          })
        } else {
          resolve('Platform and arch are different than this system, cannot display ffmpeg version') 
        }
      })
    }, 1000))
    .pipe(fs.createWriteStream(tmp, { mode: 0o755 }))
  })
}