Provides the raw __path__.  Incompatible with PEP 302-based import
    hooks and incompatible with zip_safe packages.

    Deprecated.  Will be removed by calmjs-4.0.
323798
def modpath_all(module, entry_point):
    

    module_paths = getattr(module, '__path__', [])
    if not module_paths:
        logger.warning(
            "module '%s' does not appear to be a namespace module or does not "
            "export available paths onto the filesystem; JavaScript source "
            "files cannot be extracted from this module.", module.__name__
        )
    return module_paths
939164
def get_from_package(package_name, path):
    
    filepath = pkg_resources.resource_filename(package_name, path)
    return os.path.abspath(filepath)
462168
def modpath_pkg_resources(module, entry_point):
    

    result = []
    try:
        path = resource_filename_mod_entry_point(module.__name__, entry_point)
    except ImportError:
        logger.warning("module '%s' could not be imported", module.__name__)
    except Exception:
        logger.warning("%r does not appear to be a valid module", module)
    else:
        if path:
            result.append(path)
    return result
961045
def parse(self, importpath):
		
		# reset default values
		self.native = False
		self._prefix = ""
		self._package = ""

		url = re.sub(r'http://', '', importpath)
		url = re.sub(r'https://', '', url)

		# is import path native package?
		if url.split('/')[0] in self.native_packages["packages"]:
			self.native = True
			return self

		for regex in self.known_ipprefixes:
			match = re.search(regex, url)
			if match:
				self._prefix = match.group(1)
				if match.group(3):
					self._package = match.group(3)
				return self

		raise ValueError("Import path prefix for '%s' not recognized" % importpath)
212441
def find_path_package(thepath):
    
    pname = find_path_package_name(thepath)
    if not pname:
        return None
    fromlist = b'' if six.PY2 else ''
    return __import__(pname, globals(), locals(), [fromlist])
366879
def import_dangerfile_from_path(path)
      raise "`import_dangerfile_from_path` requires a string" unless path.kind_of?(String)
      local_path = File.join(path, "Dangerfile")
      @dangerfile.parse(Pathname.new(local_path))
    end
580469
def chkpath(path):
    
    if os.path.exists(path):
        return path
    else:
        msg = "{0} does not exist.".format(path)
        raise argparse.ArgumentTypeError(msg)
257680
function parsePackageJson(path) {
    return fs.readFile(path)
        .catch(function () {
            var err = new Error(common.i18n.t('errors.utils.parsepackagejson.couldNotReadPackage'));
            err.context = path;

            return Promise.reject(err);
        })
        .then(function (source) {
            var hasRequiredKeys, json, err;

            try {
                json = JSON.parse(source);

                hasRequiredKeys = json.name && json.version;

                if (!hasRequiredKeys) {
                    err = new Error(common.i18n.t('errors.utils.parsepackagejson.nameOrVersionMissing'));
                    err.context = path;
                    err.help = common.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://docs.ghost.org/api/handlebars-themes/'});

                    return Promise.reject(err);
                }

                return json;
            } catch (parseError) {
                err = new Error(common.i18n.t('errors.utils.parsepackagejson.themeFileIsMalformed'));
                err.context = path;
                err.help = common.i18n.t('errors.utils.parsepackagejson.willBeRequired', {url: 'https://docs.ghost.org/api/handlebars-themes/'});

                return Promise.reject(err);
            }
        });
}
977345
def load_path(self, path):
        '''
        
        '''
        containing_module, _, last_item = path.rpartition('.')
        if last_item[0].isupper():
            # Is a class definition, should do an "import from"
            path = containing_module
        imported_obj = importlib.import_module(path)
        if last_item[0].isupper():
            try:
                imported_obj = getattr(imported_obj, last_item)
            except AttributeError:
                msg = 'Cannot import "%s". ' \
                    '(Hint: CamelCase is only for classes)' % last_item
                raise ConfigurationError(msg)
        return imported_obj
508458
def import_and_wrap_deprecated(module_name, module_dict, warn_import=True):
    
    if warn_import:
        deprecated_import(module_name)

    from importlib import import_module
    module = import_module(module_name)
    for attr in module.__all__:
        module_dict[attr] = deprecated(getattr(module, attr))
77848
def _path_to_module(path):
    
    # Split of preceeding path elements:
    path = "rapport" + path.split("rapport")[1]
    # Split of ending and replace os.sep with dots:
    path = path.replace(os.sep, ".").rsplit(".", 1)[0]
    return path
967786
def generate_handler_sourcepath(
            self, toolchain, spec, loaderplugin_sourcepath):
        

        # TODO calmjs-4.0.0 consider formalizing to the method instead
        npm_pkg_name = (
            self.node_module_pkg_name
            if self.node_module_pkg_name else
            self.find_node_module_pkg_name(toolchain, spec)
        )

        if not npm_pkg_name:
            cls = type(self)
            registry_name = getattr(
                self.registry, 'registry_name', '<invalid_registry/handler>')
            if cls is NPMLoaderPluginHandler:
                logger.error(
                    "no npm package name specified or could be resolved for "
                    "loaderplugin '%s' of registry '%s'; please subclass "
                    "%s:%s such that the npm package name become specified",
                    self.name, registry_name, cls.__module__, cls.__name__,
                )
            else:
                logger.error(
                    "no npm package name specified or could be resolved for "
                    "loaderplugin '%s' of registry '%s'; implementation of "
                    "%s:%s may be at fault",
                    self.name, registry_name, cls.__module__, cls.__name__,
                )
            return {}

        working_dir = spec.get(WORKING_DIR, None)
        if working_dir is None:
            logger.info(
                "attempting to derive working directory using %s, as the "
                "provided spec is missing working_dir", toolchain
            )
            working_dir = toolchain.join_cwd()

        logger.debug("deriving npm loader plugin from '%s'", working_dir)

        target = locate_package_entry_file(working_dir, npm_pkg_name)
        if target:
            logger.debug('picked %r for loader plugin %r', target, self.name)
            # use the parent recursive lookup.
            result = super(
                NPMLoaderPluginHandler, self).generate_handler_sourcepath(
                    toolchain, spec, loaderplugin_sourcepath)
            result.update({self.name: target})
            return result

        # the expected package file is not found, use the logger to show
        # why.
        # Also note that any inner/chained loaders will be dropped.
        if exists(join(
                working_dir, 'node_modules', npm_pkg_name,
                'package.json')):
            logger.warning(
                "'package.json' for the npm package '%s' does not contain a "
                "valid entry point: sources required for loader plugin '%s' "
                "cannot be included automatically; the build process may fail",
                npm_pkg_name, self.name,
            )
        else:
            logger.warning(
                "could not locate 'package.json' for the npm package '%s' "
                "which was specified to contain the loader plugin '%s' in the "
                "current working directory '%s'; the missing package may "
                "be installed by running 'npm install %s' for the mean time "
                "as a workaround, though the package that owns that source "
                "file that has this requirement should declare an explicit "
                "dependency; the build process may fail",
                npm_pkg_name, self.name, working_dir,
                npm_pkg_name,
            )

        return {}
239109
def import_by_path(path):

    """"""

    sys.path.append(os.path.dirname(path))
    try:
        return __import__(os.path.basename(path))
    except ImportError:
        logger.warn('unable to import {0}'.format(path))
    finally:
        del sys.path[-1]
409246
def unsafe(self):
        
        (scheme, netloc, path, params, query, frag) = urlparse(self.src_uri)
        if (scheme != ''):
            return(False)
        s = os.path.normpath(self.src_uri)
        d = os.path.normpath(self.dst_path)
        lcp = os.path.commonprefix([s, d])
        return(s == lcp or d == lcp)
669373
def _get_fqn(cls, path):
        
        name_list = [path.stem]
        current_path = path
        # move to parent path until parent path is a python package
        while cls.is_pkg(current_path.parent):
            name_list.append(current_path.parent.name)
            current_path = current_path.parent
        return list(reversed(name_list))
766785
function formatAsElegantPath(path, sep) {
    const chalk = require('chalk');
    const packages = path.split(sep);
    const lastIndex = packages.length - 1;

    // prettier-ignore
    const result = packages
        .map((item) => item.trim())
        .map((item, index) => {
            return index === lastIndex
                ? chalk.red.bold(item)
                : item;
        })
        .join(' -> ');
    return result;
}
1286027
function pkgdir() {
	var parts,
		len,
		str,
		i;

	parts = cwd().split( path.sep );
	len = parts.length;
	for ( i = 0; i < len; i++ ) {
		str = parts.join( path.sep );
		if ( exists( path.join( str, 'package.json' ) ) ) {
			return str;
		}
		parts.pop();
	}
	return null;
}