MCPcopy Create free account
hub / github.com/ipython/ipython / _survives_exclude

Method _survives_exclude

docs/sphinxext/apigen.py:298–337  ·  view source on GitHub ↗

Returns True if *matchstr* does not match patterns ``self.package_name`` removed from front of string if present Examples -------- >>> dw = ApiDocWriter('sphinx') >>> dw._survives_exclude('sphinx.okpkg', 'package') True >>> dw.package_skip_p

(self, matchstr, match_type)

Source from the content-addressed store, hash-verified

296 return ad
297
298 def _survives_exclude(self, matchstr, match_type):
299 ''' Returns True if *matchstr* does not match patterns
300
301 ``self.package_name`` removed from front of string if present
302
303 Examples
304 --------
305 >>> dw = ApiDocWriter('sphinx')
306 >>> dw._survives_exclude('sphinx.okpkg', 'package')
307 True
308 >>> dw.package_skip_patterns.append('^\\.badpkg$')
309 >>> dw._survives_exclude('sphinx.badpkg', 'package')
310 False
311 >>> dw._survives_exclude('sphinx.badpkg', 'module')
312 True
313 >>> dw._survives_exclude('sphinx.badmod', 'module')
314 True
315 >>> dw.module_skip_patterns.append('^\\.badmod$')
316 >>> dw._survives_exclude('sphinx.badmod', 'module')
317 False
318 '''
319 if match_type == 'module':
320 patterns = self.module_skip_patterns
321 elif match_type == 'package':
322 patterns = self.package_skip_patterns
323 else:
324 raise ValueError('Cannot interpret match type "%s"'
325 % match_type)
326 # Match to URI without package name
327 L = len(self.package_name)
328 if matchstr[:L] == self.package_name:
329 matchstr = matchstr[L:]
330 for pat in patterns:
331 try:
332 pat.search
333 except AttributeError:
334 pat = re.compile(pat)
335 if pat.search(matchstr):
336 return False
337 return True
338
339 def discover_modules(self):
340 ''' Return module sequence discovered from ``self.package_name``

Callers 1

discover_modulesMethod · 0.95

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected