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

Class SList

IPython/utils/text.py:99–255  ·  view source on GitHub ↗

List derivative with a special access attributes. These are normal lists, but with the special attributes: * .l (or .list) : value as list (the list itself). * .n (or .nlstr): value as a string, joined on newlines. * .s (or .spstr): value as a string, joined on spaces. * .p (or

Source from the content-addressed store, hash-verified

97
98
99class SList(list[Any]):
100 """List derivative with a special access attributes.
101
102 These are normal lists, but with the special attributes:
103
104 * .l (or .list) : value as list (the list itself).
105 * .n (or .nlstr): value as a string, joined on newlines.
106 * .s (or .spstr): value as a string, joined on spaces.
107 * .p (or .paths): list of path objects (requires path.py package)
108
109 Any values which require transformations are computed only once and
110 cached."""
111
112 __spstr: str
113 __nlstr: str
114 __paths: List[Path]
115
116 def get_list(self) -> Self:
117 return self
118
119 l = list = property(get_list)
120
121 def get_spstr(self) -> str:
122 try:
123 return self.__spstr
124 except AttributeError:
125 self.__spstr = ' '.join(self)
126 return self.__spstr
127
128 s = spstr = property(get_spstr)
129
130 def get_nlstr(self) -> str:
131 try:
132 return self.__nlstr
133 except AttributeError:
134 self.__nlstr = '\n'.join(self)
135 return self.__nlstr
136
137 n = nlstr = property(get_nlstr)
138
139 def get_paths(self) -> List[Path]:
140 try:
141 return self.__paths
142 except AttributeError:
143 self.__paths = [Path(p) for p in self if os.path.exists(p)]
144 return self.__paths
145
146 p = paths = property(get_paths)
147
148 def grep(
149 self,
150 pattern: Union[str, Callable[[Any], re.Match[str] | None]],
151 prune: bool = False,
152 field: Optional[int] = None,
153 ) -> Self:
154 """Return all strings matching 'pattern' (a regex or callable)
155
156 This is case-insensitive. If prune is true, return all items

Callers 4

store_or_executeMethod · 0.90
getoutputMethod · 0.90
fieldsMethod · 0.85
sortMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…