This method tries the find the BundleFile in the root of
the given package. At this moment we don't support bundles
that don't have the Bundle file in the package root.
180014
protected function findBundleFiles(PackageInterface $package)
    {
        $installPath = $this->composer->getInstallationManager()->getInstallPath($package);

        $autoload = $package->getAutoload();
        if (isset($autoload['psr-0'])) {
            $installPath .= '/' . current($autoload['psr-0']);
        }
        if (isset($autoload['psr-4'])) {
            $installPath .= '/' . current($autoload['psr-4']);
        }

        return glob(rtrim($installPath, '/') . '/*Bundle.php');
    }
1167566
public void startBundle(Bundle bundle)
    {
        if (bundle != null)
            if ((bundle.getState() != Bundle.ACTIVE) && (bundle.getState() != Bundle.STARTING))
        {
            try {
                bundle.start();
            } catch (BundleException e) {
                e.printStackTrace();
            }
        }
    }
513599
private static BundleContext checkBundleContext() {
        if (bundleContext == null) {
            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "BundleContext is null and should not be");
            }
        }
        return bundleContext;
    }
1090305
private void processPackage(File root, File dir) {
        getLog().debug("- package: " + dir);
        if (null != dir && dir.isDirectory()) {
            for (File f : dir.listFiles(new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                    return pathname.isDirectory() || pathname.getName().endsWith(".class");
                }
            })) {
                if (f.isDirectory()) {
                    processPackage(root, f);
                } else if (f.getParentFile().getAbsolutePath().replace(File.separatorChar, '.').endsWith(basePackage + '.' + domainPackageName)) {
                    final String simpleName = f.getName().substring(0, f.getName().lastIndexOf(".class"));
                    final String className = String.format("%s.%s.%s", basePackage, domainPackageName, simpleName);
                    getLog().debug(String.format("--- class %s", className));
                    try {
                        Class clazz = loader.loadClass(className);
                        if (!Modifier.isAbstract(clazz.getModifiers()) && isEntity(clazz)) {
                            getLog().debug("@Entity " + clazz.getName());
                            final Entity entity = new Entity();
                            entity.setClazz(clazz);

                            final String packageName = clazz.getPackage().getName();
                            Group group = packages.get(packageName);
                            if (null == group) {
                                group = new Group();
                                group.setName(packageName);
                                packages.put(packageName, group);
                            }

                            group.getEntities().put(simpleName, entity);
                            entities.put(entity.getClassName(), entity);
                        }
                    } catch (ClassNotFoundException ex) {
                        Logger.getLogger(ProcessDomainMojo.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    }
1374226
def get_applicable_overlays(self, error_bundle):
        

        content_paths = self.get_triples(subject='content')
        if not content_paths:
            return set()

        # Create some variables that will store where the applicable content
        # instruction path references and where it links to.
        chrome_path = ''
        content_root_path = '/'

        # Look through each of the listed packages and paths.
        for path in content_paths:
            chrome_name = path['predicate']
            if not path['object']:
                continue
            path_location = path['object'].strip().split()[0]

            # Handle jarred paths differently.
            if path_location.startswith('jar:'):
                if not error_bundle.is_nested_package:
                    continue

                # Parse out the JAR and it's location within the chrome.
                split_jar_url = path_location[4:].split('!', 2)
                # Ignore invalid/unsupported JAR URLs.
                if len(split_jar_url) != 2:
                    continue

                # Unpack the JAR URL.
                jar_path, package_path = split_jar_url

                # Ignore the instruction if the JAR it points to doesn't match
                # up with the current subpackage tree.
                if jar_path != error_bundle.package_stack[0]:
                    continue
                chrome_path = self._url_chunk_join(chrome_name, package_path)
                # content_root_path stays at the default: /

                break
            else:
                # If we're in a subpackage, a content instruction referring to
                # the root of the package obviously doesn't apply.
                if error_bundle.is_nested_package:
                    continue

                chrome_path = self._url_chunk_join(chrome_name, 'content')
                content_root_path = '/%s/' % path_location.strip('/')
                break

        if not chrome_path:
            return set()

        applicable_overlays = set()
        chrome_path = 'chrome://%s' % self._url_chunk_join(chrome_path + '/')

        for overlay in self.get_triples(subject='overlay'):
            if not overlay['object']:
                error_bundle.error(
                    err_id=('chromemanifest', 'get_applicable_overalys',
                            'object'),
                    error='Overlay instruction missing a property.',
                    description='When overlays are registered in a chrome '
                                'manifest file, they require a namespace and '
                                'a chrome URL at minimum.',
                    filename=overlay['filename'],
                    line=overlay['line'],
                    context=self.context)  #TODO(basta): Update this!
                continue
            overlay_url = overlay['object'].split()[0]
            if overlay_url.startswith(chrome_path):
                overlay_relative_path = overlay_url[len(chrome_path):]
                applicable_overlays.add('/%s' %
                        self._url_chunk_join(content_root_path,
                                             overlay_relative_path))

        return applicable_overlays
675142
function findPackFile(file, packedFiles) {
    var packTo = file.packTo;
    for (var i = packedFiles.length - 1; i >= 0; i--) {
        var item = packedFiles[i];

        if (Array.isArray(packTo)) {
            if (packTo.length > 1) {
                fis.log.warning('resource %j which is packed to '
                + 'multitarget, cannot process this situation!', packTo);
                return;
            }
            packTo.length === 1 && (packTo = packTo[0]);
        }

        if (item.pkg.subpath === packTo) {
            return item;
        }
    }
}
25668
def check_package_exists(package, lib_dir):
    
    try:
        req = pkg_resources.Requirement.parse(package)
    except ValueError:
        # This is a zip file
        req = pkg_resources.Requirement.parse(urlparse(package).fragment)

    # Check packages from lib dir
    if lib_dir is not None:
        if any(dist in req for dist in
               pkg_resources.find_distributions(lib_dir)):
            return True

    # Check packages from global + virtual environment
    # pylint: disable=not-an-iterable
    return any(dist in req for dist in pkg_resources.working_set)
207214
function find(deleted, file) {
    var meta = bundle[file].meta
      , match = files.some(function some (file) {
          return file === meta.location || ~meta.location.indexOf(file)
            || (meta.compiler && ~meta.compiler.imported.join(',').indexOf(file));
        });

    if (!match) return;

    // If we check previous for deleted files, don't read content.
    if (!deleted) {
      self.hold(meta.location); // Temporary freeze of the event loop.
      self.package.bundle[file].meta.content = fs.readFileSync(meta.location, 'utf8');
    }

    // Add the file extension to the extensions list so we can create
    // a dedicated rebuild.
    extensions.push(meta.output);
    changes.push(file);
  }
534168
public static Bundle installBundle(BundleContext context, Resource bundle, boolean checkExistence) throws IOException, BundleException {
	if (checkExistence) {
	    BundleFile bf = new BundleFile(bundle);
	    if (!bf.isBundle()) throw new BundleException(bundle + " is not a valid bundle!");

	    Bundle existing = loadBundleFromLocal(context, bf.getSymbolicName(), bf.getVersion(), false, null);
	    if (existing != null) return existing;
	}

	return _loadBundle(context, bundle.getAbsolutePath(), bundle.getInputStream(), true);
    }
182761
private ResourceBundle getBundle() {
        String bundleKey = getBundleKey();
        if (bundles.containsKey(bundleKey)) {
            return bundles.get(bundleKey);
        } else {
            ResourceBundle bundle = loadBundle();
            bundles.put(bundleKey, bundle);
            return bundle;
        }
    }
263212
function recursiveBundle(bundleExt, variables, errorCallback) {
	return through2.obj(function (file, enc, cb) {
		if (!checkFile(file, cb))
			return;

		// standart file push to callback
		if (path.extname(file.path).toLowerCase() != bundleExt)
			return cb(null, file);

		// bundle file should be parsed
		processBundleFile(file, bundleExt, variables, null, errorCallback)
			.pipe(pushTo(this))
			.on('end', cb);
	});
}
1247580
public Bundle findBundle(Object objResource, Object bundleContext, String packageName, String versionRange)
    {
        if (bundleContext == null)
            bundleContext = this.bundleContext;
        if (bundleContext == null)
            return null;
        if (objResource == null)
            return BaseClassFinderService.findBundle((BundleContext)bundleContext, packageName, versionRange);
        Bundle[] bundles = ((BundleContext)bundleContext).getBundles();
        for (Bundle bundle : bundles)
        {
            if (objResource != null)
            {
                if (this.isResourceBundleMatch(objResource, bundle))
                    return bundle;               
            }
        }
        return null;
    }
721903
def find_packages(name, pkg_dir):
    """"""
    for c in (FileSystemPackageBuilder, ZipPackageBuilder, ExcelPackageBuilder):

        package_path, cache_path = c.make_package_path(pkg_dir, name)

        if package_path.exists():

            yield c.type_code, package_path, cache_path
313327
def getpackagepath():
    
    moduleDirectory = os.path.dirname(__file__)
    packagePath = os.path.dirname(__file__) + "/../"

    return packagePath
776792
def find_single_file_project(self):  # type: () -> List[str]
        
        # TODO: use package_dirs
        packaged_dirs = ""
        try:
            # Right now only returns 1st.
            packaged_dirs = self.extract_package_dir()
        except:
            pass
        likely_src_folders = [".", "src/"]
        if packaged_dirs:
            likely_src_folders.append(packaged_dirs)

        candidates = []
        for likely_src in likely_src_folders:
            if not os.path.isdir(likely_src):
                continue
            files = [f for f in os.listdir(likely_src) if os.path.isfile(f)]

            # BUG: doesn't deal with src/foo/bar.py
            for file in files:
                if file.endswith("setup.py") or file == "setup":
                    continue  # duh
                if file.endswith(".py"):
                    candidate = file.replace(".py", "")
                    if candidate != "setup":
                        candidates.append(candidate)
                else:
                    if self.file_opener.is_python_inside(file):
                        candidates.append(file)
        return candidates
1114294
private ClassLoader getClassLoaderFromBundle(Object resource, String packageName, String versionRange)
    {
    	ClassLoader classLoader = null;
        if (resource == null)
        {
            Object classAccess = this.getClassBundleService(null, packageName + FAKE_CLASSNAME, versionRange, null, 0);
            if (classAccess != null)
            {
            	classLoader = classAccess.getClass().getClassLoader();
            }
        }
        else
        {
        	Bundle bundle = this.findBundle(resource, bundleContext, packageName, versionRange);
        	if (bundle == null)
        		return null;
        	@SuppressWarnings("unchecked")
			Enumeration<URL> entries = bundle.findEntries(packageName.replace('.', '/'), "*.class", true);
        	if (entries != null)
        		if (entries.hasMoreElements())
        	{	// This is kind of a hokey way to get the classloader from a bundle - find a class file and load it - but it works.
        		URL url = entries.nextElement();
        		String path = url.getFile();
        		int start = path.startsWith("/") ? 1 : 0;	// Path should always start at the root.
        		path = path.substring(start, path.lastIndexOf('.')).replace('/', '.');
        		try {
					classLoader = bundle.loadClass(path).getClassLoader();
				} catch (ClassNotFoundException e) {
					e.printStackTrace();
				}
        	}
        }
        return classLoader;
    }
627427
function isManifest(bundleName, filePath) {
	return path.dirname(filePath).endsWith(bundleName) && path.basename(filePath) === 'package.json';
}