Prune a package graph so it only contains nodes accessible from the
    given package.

    Args:
        graph_str (str): Dot-language graph string.
        package_name (str): Name of package of interest.

    Returns:
        Pruned graph, as a string.
189022
def prune_graph(graph_str, package_name):
    
    # find nodes of interest
    g = read_dot(graph_str)
    nodes = set()

    for node, attrs in g.node_attr.iteritems():
        attr = [x for x in attrs if x[0] == "label"]
        if attr:
            label = attr[0][1]
            try:
                req_str = _request_from_label(label)
                request = PackageRequest(req_str)
            except PackageRequestError:
                continue

            if request.name == package_name:
                nodes.add(node)

    if not nodes:
        raise ValueError("The package %r does not appear in the graph."
                         % package_name)

    # find nodes upstream from these nodes
    g_rev = g.reverse()
    accessible_nodes = set()
    access = accessibility(g_rev)
    for node in nodes:
        nodes_ = access.get(node, [])
        accessible_nodes |= set(nodes_)

    # remove inaccessible nodes
    inaccessible_nodes = set(g.nodes()) - accessible_nodes
    for node in inaccessible_nodes:
        g.del_node(node)

    return write_dot(g)
704239
def remove(self, pkgs):
        
        print("\nRemove packages from the blacklist:\n")
        with open(self.blackfile, "w") as remove:
            for line in self.black_conf.splitlines():
                if line not in pkgs:
                    remove.write(line + "\n")
                else:
                    print("{0}{1}{2}".format(self.meta.color["RED"], line,
                                             self.meta.color["ENDC"]))
                    self.quit = True
            remove.close()
        if self.quit:
            print("")
702177
def contains_project_name(name, link):
    
    def unclutter(string):
        # strip out all python references and remove all excessive characters
        string = string.lower().replace("_", "-").replace(".", "-")
        for replace in ["python-", "py-", "-py", "-python"]:
            string = string.replace(replace, "")
        return re.sub("[^0123456789 a-zA-Z]", "", string).strip()
    return unclutter(name) in unclutter(link)
1018484
def remove_package(self, team, user, package):
        
        self.check_name(team, user, package)

        path = self.package_path(team, user, package)
        remove_objs = set()
        # TODO: do we really want to delete invisible dirs?
        if os.path.isdir(path):
            # Collect objects from all instances for potential cleanup
            contents_path = os.path.join(path, PackageStore.CONTENTS_DIR)
            for instance in os.listdir(contents_path):
                pkg = self.get_package(team, user, package, pkghash=instance)
                remove_objs.update(find_object_hashes(pkg))
            # Remove package manifests
            rmtree(path)

        return self.prune(remove_objs)
387381
def get_realnames(packages):
    
    return sorted({get_distribution(p).project_name for p in packages},
                  key=lambda n: n.lower())
827131
def remove_node_attributes(G: nx.DiGraph, attributes: Union[str, Iterable[str]]):
    
    G = G.copy()
    for _, data in G.nodes(data=True):
        for attribute in setwrap(attributes):
            if attribute in data:
                del data[attribute]
    return G
364136
def get_neighborhood_network(self, node_name: str, order: int = 1) -> Graph:
        
        logger.info("In get_neighborhood_graph()")
        neighbors = list(self.get_neighbor_names(node_name, order))
        neighbor_network = self.graph.copy()
        neighbor_network.delete_vertices(self.graph.vs.select(name_notin=neighbors))
        return neighbor_network
72706
def delete_node(self, node_name, graph=None):
        
        if not graph:
            graph = self.graph
        if node_name not in graph:
            raise KeyError('node %s does not exist' % node_name)
        graph.pop(node_name)

        for node, edges in six.iteritems(graph):
            if node_name in edges:
                edges.remove(node_name)
158237
def remove_filtered_nodes(graph, node_predicates=None):
    
    nodes = list(filter_nodes(graph, node_predicates=node_predicates))
    graph.remove_nodes_from(nodes)
756896
def _pipdeptree(python_bin, package_name: str = None, warn: bool = False) -> typing.Optional[dict]:
    """"""
    cmd = "{} -m pipdeptree --json".format(python_bin)

    _LOGGER.debug("Obtaining pip dependency tree using: %r", cmd)
    output = run_command(cmd, is_json=True).stdout

    if not package_name:
        return output

    for entry in output:
        # In some versions pipdeptree does not work with --packages flag, do the logic on out own.
        # TODO: we should probably do difference of reference this output and original environment
        if entry["package"]["key"].lower() == package_name.lower():
            return entry

    # The given package was not found.
    if warn:
        _LOGGER.warning("Package %r was not found in pipdeptree output %r", package_name, output)
    return None
435653
def pruned(name, user=None, env=None):
    '''
    

    '''
    ret = {'name': name, 'result': None, 'comment': '', 'changes': {}}

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'Directory \'{0}\' is set to be pruned'.format(
            name)
        return ret

    try:
        call = __salt__['bower.prune'](dir=name, runas=user, env=env)
    except (CommandNotFoundError, CommandExecutionError) as err:
        ret['result'] = False
        ret['comment'] = 'Error pruning \'{0}\': {1}'.format(name, err)
        return ret

    ret['result'] = True
    if call:
        ret['comment'] = 'Directory \'{0}\' was successfully pruned'.format(name)
        ret['changes'] = {'old': [], 'new': call}
    else:
        ret['comment'] = 'No packages were pruned from directory \'{0}\''.format(name)

    return ret
452794
def truncateGraph(graph, root_nodes):
		
		subgraph = Graph()
		for node in root_nodes:
			subgraph = GraphUtils.joinGraphs(subgraph, GraphUtils.getReacheableSubgraph(graph, node))

		return subgraph
850105
def get_string(self):
        
        graph_string = self.graph.to_string()
        graph_string = graph_string.replace('\\N', '\\n')
        return graph_string
375821
def package(*args: str) -> str:
    

    return clean(os.path.join(os.path.dirname(__file__), '..', *args))
926234
def remove(package_name):
    
    if package_name not in packages:
        raise HolodeckException("Unknown package name " + package_name)
    for config, path in _iter_packages():
        if config["name"] == package_name:
            shutil.rmtree(path)
712483
def _get_package_name(module):
    
    try:
        # if __package__ is defined, use it
        package_name = module.__package__
    except AttributeError:
        package_name = None  
        
    if package_name is None:
        # if __path__ is defined, the package name is the module name
        package_name = module.__name__
        if not hasattr(module, '__path__'):
            # if __path__ is not defined, the package name is the
            # string before the last "." of the fully-qualified module name
            package_name = package_name.rpartition('.')[0]
           
    return package_name
758763
function (projectDir)
  {
    "use strict";
    const packageJson = readPackageJson(projectDir);
    const extracted = extractVendors(packageJson);

    return extracted.filter(function (packageName) { return startsWith(packageName, '@deskpro/'); });
  }