##// END OF EJS Templates
Remove unused *grep functions
Thomas Kluyver -
Show More
@@ -321,48 +321,6 b' def qw_lol(indata):'
321 return qw(indata)
321 return qw(indata)
322
322
323
323
324 def grep(pat,list,case=1):
325 """Simple minded grep-like function.
326 grep(pat,list) returns occurrences of pat in list, None on failure.
327
328 It only does simple string matching, with no support for regexps. Use the
329 option case=0 for case-insensitive matching."""
330
331 # This is pretty crude. At least it should implement copying only references
332 # to the original data in case it's big. Now it copies the data for output.
333 out=[]
334 if case:
335 for term in list:
336 if term.find(pat)>-1: out.append(term)
337 else:
338 lpat=pat.lower()
339 for term in list:
340 if term.lower().find(lpat)>-1: out.append(term)
341
342 if len(out): return out
343 else: return None
344
345
346 def dgrep(pat,*opts):
347 """Return grep() on dir()+dir(__builtins__).
348
349 A very common use of grep() when working interactively."""
350
351 return grep(pat,dir(__main__)+dir(__main__.__builtins__),*opts)
352
353
354 def idgrep(pat):
355 """Case-insensitive dgrep()"""
356
357 return dgrep(pat,0)
358
359
360 def igrep(pat,list):
361 """Synonym for case-insensitive grep."""
362
363 return grep(pat,list,case=0)
364
365
366 def indent(instr,nspaces=4, ntabs=0, flatten=False):
324 def indent(instr,nspaces=4, ntabs=0, flatten=False):
367 """Indent a string a given number of spaces or tabstops.
325 """Indent a string a given number of spaces or tabstops.
368
326
General Comments 0
You need to be logged in to leave comments. Login now