MCPcopy Index your code
hub / github.com/ipython/ipython / filter_ns

Function filter_ns

IPython/utils/wildcard.py:75–87  ·  view source on GitHub ↗

Filter a namespace dictionary by name pattern and item type.

(ns, name_pattern="*", type_pattern="all", ignore_case=True,
            show_all=True)

Source from the content-addressed store, hash-verified

73 return ns
74
75def filter_ns(ns, name_pattern="*", type_pattern="all", ignore_case=True,
76 show_all=True):
77 """Filter a namespace dictionary by name pattern and item type."""
78 pattern = name_pattern.replace("*",".*").replace("?",".")
79 if ignore_case:
80 reg = re.compile(pattern+"$", re.I)
81 else:
82 reg = re.compile(pattern+"$")
83
84 # Check each one matches regex; shouldn't be hidden; of correct type.
85 return dict((key,obj) for key, obj in ns.items() if reg.match(key) \
86 and show_hidden(key, show_all) \
87 and is_type(obj, type_pattern) )
88
89def list_namespace(namespace, type_pattern, filter, ignore_case=False, show_all=False):
90 """Return dictionary of all objects in a namespace dictionary that match

Callers 1

list_namespaceFunction · 0.85

Calls 4

show_hiddenFunction · 0.85
is_typeFunction · 0.85
replaceMethod · 0.80
matchMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…