Walk source directory tree and convert each sub directory to a
    package name.
335549
def find_packages():
    
    packages = ['pyctools']
    for root, dirs, files in os.walk(os.path.join('src', 'pyctools')):
        package = '.'.join(root.split(os.sep)[1:])
        for name in dirs:
            packages.append(package + '.' + name)
    return packages
1240665
function buildDependencyTreeFromSources(filenames, sourcesObject) {
  const orgnizedFlat = {};

  // build tree object
  filenames.forEach(sourceFileName => {
    orgnizedFlat[sourceFileName] = {
      path: sourceFileName,
      source: sourcesObject[sourceFileName],
      dependencies: buildDependencyTreeFromSources(allImportPaths(sourcesObject[sourceFileName]), sourcesObject),
    };
  });

  // return organized object
  return orgnizedFlat;
}
1166673
def recursive_path(pack, path):
    """"""
    matches = []
    for root, _, filenames in os.walk(os.path.join(pack, path)):
        for filename in filenames:
            matches.append(os.path.join(root, filename)[len(pack) + 1:])
    return matches
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);
                    }
                }
            }
        }
    }
1173638
def pkg_name_to_path(pkgname):
    

    logger.debug("'%s'", pkgname)

    fp = os.path.join(settings.upkg_destdir, pkgname)
    if os.path.isdir(fp):
        logger.debug("found %s", fp)
        return fp

    # Try to find the repo dir if just needs an extension
    for d in repo_dirlist():
        logger.debug("trying %s", d)
        if d['base'].startswith(pkgname):
            # logger.debug("startwith")
            root, ext = os.path.splitext(d['base'])
            if pkgname == root:
                logger.debug("found %s", d)
                return d['path']
    # end for d in dlist

    logger.debug("found nothing")
    return ""
817104
def module_to_package_data(
        name: str,
        entry,
        path_prefixes: list = None
) -> typing.Union[dict, None]:
    

    if name.find('.') > -1:
        # Not interested in sub-packages, only root ones
        return None

    version = getattr(entry, '__version__', None)
    version = version if not hasattr(version, 'version') else version.version
    location = getattr(entry, '__file__', sys.exec_prefix)

    if version is None or location.startswith(sys.exec_prefix):
        # Not interested in core packages. They obviously are standard and
        # don't need to be included in an output.
        return None

    return dict(
        name=name,
        version=version,
        location=simplify_path(location, path_prefixes)
    )
281545
def pathify(basenames, examples_dir="examples/"):  # pragma: no cover
    """"""
    example = examples_dir.replace("/", ".")
    return [example + basename for basename in basenames]
36858
function normalizePackage(parent) {
    parent.packages = parent.packages && parent.packages.map(function (item) {
      if (typeof item === 'string') {
        item = {
          name: item
        };
      }

      var folder = item.location || item.name;

      item.isFISID = isFISID(folder);
      item.folder = item.isFISID ? folder : path.join(baseUrl, item.location || item.name);
      pkgs[item.name] = item;

      if (item.packages) {
        normalizePackage(item)
      }

      return item;
    });
  }
127344
def _source_roots_for_target(target):
    
    def root_package_prefix(source_file):
      source = os.path.dirname(source_file)
      return os.path.join(get_buildroot(), target.target_base, source), source.replace(os.sep, '.')
    return {root_package_prefix(source) for source in target.sources_relative_to_source_root()}
361395
def _from_directory(self, dirname, prefix=""):
        
        ps = [os.path.join(here, dirname, p) for p in os.listdir(os.path.join(here, dirname))]
        n = prefix + wt_kit.string2identifier(os.path.basename(dirname))
        setattr(self, n, ps)
887081
def __rename_directory(self, source, target):
        

        for node in itertools.chain(self.__script_editor.model.get_project_nodes(source),
                                    self.__script_editor.model.get_directory_nodes(source)):
            self.__script_editor.model.unregister_project_nodes(node)
            self.__script_editor.unregister_node_path(node)
            self.__rename_path(source, target)
            node.name = os.path.basename(target)
            node.path = target
            self.__script_editor.model.node_changed(node)
            self.__script_editor.register_node_path(node)
            self.__script_editor.model.set_project_nodes(node)
1276650
def removed_tree(self, dirname):
        """"""
        dirname = osp.abspath(to_text_string(dirname))
        for fname in self.get_filenames():
            if osp.abspath(fname).startswith(dirname):
                self.close_file_from_name(fname)
948899
def _to_relative_path(cls, parent_repo, path):
        """"""
        path = to_native_path_linux(path)
        if path.endswith('/'):
            path = path[:-1]
        # END handle trailing slash

        if osp.isabs(path):
            working_tree_linux = to_native_path_linux(parent_repo.working_tree_dir)
            if not path.startswith(working_tree_linux):
                raise ValueError("Submodule checkout path '%s' needs to be within the parents repository at '%s'"
                                 % (working_tree_linux, path))
            path = path[len(working_tree_linux.rstrip('/')) + 1:]
            if not path:
                raise ValueError("Absolute submodule path '%s' didn't yield a valid relative path" % path)
            # end verify converted relative path makes sense
        # end convert to a relative path

        return path
1078951
def R_package_path(package):
    
    local_sitelib = R_sitelib()
    rscript = Rscript_cmd()
    cmd = """{rscript} --no-environ -e '.libPaths(c("{local_sitelib}")); find.package("{package}")'"""
    try:
        output = subprocess.check_output(cmd.format(**locals()), shell=True)
    except subprocess.CalledProcessError as e:
        return None
    for line in output.decode().split("\n"):
        if "[1]" not in line:
            continue
        dirname = line.split("[1]")[1].replace("\"", "").strip()
        if os.path.exists(dirname):
            return dirname
    return None
1218637
def include_dir(self, root):
        """"""
        parts = [root]
        parts.extend(self.pathname.split(os.path.sep))
        return "/".join(parts)
277490
private StringBuilder makeNewPackageName(final StringBuilder packageName, final File dir) {
		if (packageName.length() == 0) {
			return new StringBuilder(dir.getName());
		} else {
			return new StringBuilder(packageName).append(PATH_SEPARATOR).append(dir.getName());
		}
	}
192867
function buildTree(directory, barrelName, logger) {
    logger(`Building directory tree for ${utilities_1.convertPathSeparator(directory)}`);
    const names = fs_1.default.readdirSync(directory);
    const result = {
        directories: [],
        files: [],
        name: path_1.default.basename(directory),
        path: utilities_1.convertPathSeparator(directory)
    };
    names.forEach((name) => {
        const fullPath = path_1.default.join(directory, name);
        if (fs_1.default.statSync(fullPath).isDirectory()) {
            result.directories.push(buildTree(fullPath, barrelName, logger));
        }
        else {
            const convertedPath = utilities_1.convertPathSeparator(fullPath);
            const file = {
                name,
                path: convertedPath
            };
            result.files.push(file);
            if (file.name === barrelName) {
                logger(`Found existing barrel @ ${convertedPath}`);
                result.barrel = file;
            }
        }
    });
    return result;
}