Find app's and widgets root directories over composer psr loader
175345
private function parseComposerLoader(): void
    {
        // get composer autoload map
        $map = $this->loader->getPrefixes();
        if (Any::isArray($map)) {
            // get all available apps root dirs by psr loader for apps
            if (array_key_exists('Apps\\', $map)) {
                foreach ($map['Apps\\'] as $appPath) {
                    $this->appRoots[] = $appPath;
                }
            }

            // get Widgets map
            if (array_key_exists('Widgets\\', $map)) {
                // get all available root dirs by psr loader for widgets
                foreach ($map['Widgets\\'] as $widgetPath) {
                    $this->widgetRoots[] = $widgetPath;
                }
            }
        }

        // set default root path if not found anything else
        if (count($this->appRoots) < 1) {
            $this->appRoots = [root];
        }

        if (count($this->widgetRoots) < 1) {
            $this->widgetRoots = [root];
        }
    }
68903
public static function GeAppFullPath () {
		static $app_full_path;
		if (!isset($app_full_path)) {
			if (!is_null($composer_loader = ClassLoader::GetComposerLoader())) {
				$psr4_map = $composer_loader->getPrefixesPsr4();
				for ($base_app_path = $app_path = str_replace("/", "\\", rtrim(static::GetAppPath(), '/')) . "\\"; !isset($psr4_map[$app_path]) && $app_path !== "\\"; $app_path = mb_substr($app_path, 0, mb_strrpos($app_path, "\\", -2)) . "\\");
			}

			if (isset($psr4_map[$app_path])) {
				$app_full_path = str_replace("\\", '/', str_replace($app_path, realpath($psr4_map[$app_path][0]) . '/', $base_app_path));
			}

			$vendor_dir = static::GetVendorPath();

			isset($app_full_path) && file_exists($app_full_path)
			 ?: file_exists($app_full_path = dirname($vendor_dir) . '/' . static::GetAppPath())
			 ?: file_exists($app_full_path = $vendor_dir .'/'. static::GetAppPath())
			 ?: false;
		}

		return $app_full_path;
	}
163984
public function GetSolutionDirectoryList(\Puzzlout\Framework\Core\Application $app) {
        $Cacher = \Puzzlout\Framework\Core\Cache\BaseCache::Init($app->config);
        //$Cacher->Remove(CacheKeys::SOLUTION_FOLDERS);
        if (!$Cacher->KeyExists(CacheKeys::SOLUTION_FOLDERS)) {
            $SolutionPathListArray = ArrayFilterDirectorySearch::Init($app)->RecursiveScanOf(
                    "APP_ROOT_DIR", \Puzzlout\Framework\Core\DirectoryManager\Algorithms\ArrayListAlgorithm::ExcludeList());
            $Cacher->Create(CacheKeys::SOLUTION_FOLDERS, $SolutionPathListArray);
        } else {
            $SolutionPathListArray = $Cacher->Read(CacheKeys::SOLUTION_FOLDERS, array());
        }
        return $SolutionPathListArray;
    }
823561
public function getAssets()
    {
        //this is the app directory.
        //the console is in this directory
        $rootDir = $this->container->get('kernel')->getRootDir();
        $appOverrideDir = '/Resources';

        $resources = [];
        $finder = new Finder();
        $finder->files()->name('assetic_injector.json');
        foreach ($this->container->get('kernel')->getBundles() as $bundle) {
            //the number of files found in the override path
            $finderCount = 0;
            //the bundle name
            $bundleName = $bundle->getName();

            //the override path
            $overridePath = $rootDir.$appOverrideDir.'/'.$bundleName.'/config/';

            //does the file exists in the app/Resources
            if (file_exists($overridePath)) {
                $finder->in($overridePath);
                $finderCount = $finder->count();
            }

            //if no files were found
            if ($finderCount === 0) {
                if (file_exists($bundle->getPath().'/Resources/config/')) {
                    $finder->in($bundle->getPath().'/Resources/config/');
                }
            }
        }
        $injectArray = [];
        foreach ($finder as $file) {
            $json = file_get_contents($file);
            if (is_array(json_decode($json, true))) {
                $injectArray = array_merge_recursive($injectArray, json_decode($json, true));
            }
        }

        foreach ($injectArray as $engine => $assets) {
            $engine = $this->container->get('assetic_injector.'.$engine);
            $engine->compute($assets);
            $resources = array_merge_recursive($resources, $engine->getResources());
        }

        return $resources;
    }
1308851
function findProjectRoot(startPath) {
    log.trace("findProjectRoot startPath = %s", startPath);
    if(isDiskRoot()) {
      if(hasPackageJson()) {
        return startPath;
      } else {
        throw new Error("Cannot find project root");
      }
    } else if(hasPackageJson()) {
      return startPath;
    } else {
      return findProjectRoot(PATH.resolve(startPath+PATH.sep+".."));
    }

    function hasPackageJson() {
      return fs.existsSync(startPath+PATH.sep+"package.json");
    }

    function isDiskRoot() {
      return startPath.match(/^([A-Z]:\\\\|\/)$/);
    }
  }
604280
def find_packages(root_directory: str = '.') -> t.List[str]:
    """"""
    exclude = ['test*', 'test.*'] if ('bdist_wheel' in sys.argv or 'bdist' in sys.argv) else []
    packages_list = setuptools.find_packages(root_directory, exclude=exclude)
    return packages_list
1031179
def did_composer_install(dir):
    '''
    
    '''
    lockFile = "{0}/vendor".format(dir)
    if os.path.exists(lockFile):
        return True
    return False
1062646
protected function retrieveInstalledBundles()
    {
        $finder = new Finder();
        $autoloaders = $finder->files()->depth(0)->name('*.json')->in($this->autoloadersPath);
        foreach ($autoloaders as $autoloader) {
            $bundleName = strtolower(basename($autoloader->getFilename(), '.json'));
            $jsonAutoloader = new JsonAutoloader($bundleName, (string)$autoloader);
            $this->installedBundles[$bundleName] = $jsonAutoloader;
        }
    }
342382
private function getRootDir($checkPath)
    {
        $dir = $checkPath;
        while (!file_exists($dir . '/composer.json')) {
            if ($dir === dirname($dir)) {
                break;
            }
            $dir = dirname($dir);
        }

        return $dir;
    }
446870
def get_modules(root_path):
    """"""
    for dir_path, dir_names, file_names in os.walk(root_path):
        assert dir_path[:len(root_path)] == root_path
        subdir_path = dir_path[len(root_path):]
        package_parts = list(filter(lambda x: x, subdir_path.split('/')))
        for name in file_names:
            if name.endswith('.py'):
                path = os.path.join(dir_path, name)
                pkgpath = '.'.join(package_parts)
                modpath = (pkgpath if name == '__init__.py' else
                           '.'.join(package_parts + [name[:-3]]))
                try:
                    node = ast.parse(open(path).read())
                except SyntaxError:
                    print('ERROR: Invalid syntax in %s' % path, file=sys.stderr)
                else:
                    yield (pkgpath, modpath, path, node)
900109
def _get_paths(self):
        """"""
        ret = []
        ret += ['%s/library/' % os.path.dirname(os.path.dirname(__file__))]        
        
        ret += self._extra_dirs
        for basedir in _basedirs:
            fullpath = os.path.join(basedir, self.subdir)
            if fullpath not in ret:
                ret.append(fullpath)
        ret += self.config.split(os.pathsep)
        ret += self._get_package_path()
        return ret
963932
public function getRootNamespace(): string
    {
        if (! is_null(static::$namespace)) {
            return static::$namespace;
        }

        $composer = Json::decode(file_get_contents($this->getRootPath() . '/composer.json'));

        foreach ((array) Arr::get($composer, 'autoload.psr-4', []) as $namespace => $paths) {
            foreach ((array) $paths as $path) {
                if (realpath($this->getAppPath()) === realpath($this->getRootPath() . '/' . $path)) {
                    return static::$namespace = $namespace;
                }
            }
        }


        unset($composer);

        return '';
    }
1369767
private function findProjectRoot(string $dir) : ?string
    {
        do {
            $path = $dir . '/composer.json';

            if (file_exists($path)) {
                return $dir;
            }

            $prev = $dir;
            $dir = dirname($dir);
        } while ($dir !== $prev);

        return null;
    }
707398
public function getMainPrefixAndPath(Dir $rootDir) {
    $prefixesPaths = $this->getPrefixes();
    $prefixes = array_keys($prefixesPaths);
    
    if (count($prefixes) > 0) {
      $firstPrefixPaths = array_shift($prefixesPaths);

      $path = array_shift($firstPrefixPaths);
      $dir = $path instanceof Dir ? $path : $rootDir->sub($path);
    
      return array(array_shift($prefixes), $dir);
    }
    
    throw new NoAutoLoadPrefixException('Cannot retrieve the main Prefix and Library Path from AutoLoadInfo. AutoLoadInfo is defined: '.print_r($prefixesPaths, true)."\nPlease insert autoload informations into your composer.json");
  }
658544
function findProject(folder) {
    const GLOB_PATTERN = '**/*.xcodeproj';
    const TEST_PROJECTS = /test|example|sample/i;
    const IOS_BASE = 'ios';
    const GLOB_EXCLUDE_PATTERN = ['**/@(Pods|node_modules)/**'];

    const projects = glob
        .sync(GLOB_PATTERN, {
            cwd: folder,
            ignore: GLOB_EXCLUDE_PATTERN,
        })
        .filter(project => {
            return path.dirname(project) === IOS_BASE || !TEST_PROJECTS.test(project);
        })
        .sort((projectA, projectB) => {
            return path.dirname(projectA) === IOS_BASE ? -1 : 1;
        });
  
    if (projects.length === 0) {
        return null;
    }
  
    return projects[0];
}
205697
function getProjectRootDirectory() {
  // From the current directory, check if parent directories have a package.json file and if it contains
  // a reference to the @myrmex/core node_module
  let cwd = process.cwd();
  let packageJson;
  let found = false;

  do {
    try {
      packageJson = require(path.join(cwd, 'package.json'));
      if ((packageJson.dependencies && packageJson.dependencies['@myrmex/core'])
        || (packageJson.devDependencies && packageJson.devDependencies['@myrmex/core'])) {
        found = true;
      } else {
        cwd = path.dirname(cwd);
      }
    } catch (e) {
      cwd = path.dirname(cwd);
    }
  } while (cwd !== path.dirname(cwd) && !found);
  if (found) {
    return cwd;
  }
  return false;
}
760399
def source_roots(self, document_path):
        """"""
        files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
        return [os.path.dirname(setup_py) for setup_py in files]