def testNone(self): self.assertFalse(ht.TNotNone(None)) self.assertTrue(ht.TNone(None)) for val in [0, True, "", "Hello World", [], range(5)]: self.assertTrue(ht.TNotNone(val)) self.assertFalse(ht.TNone(val))
def _ManPageRole( typ, rawtext, text, lineno, inliner, # pylint: disable=W0102 options={}, content=[]): """Custom role for man page references. Converts man pages to links if enabled during the build. """ xref = _ManPageXRefRole() assert ht.TNone(xref.converted) # Check if it's a known man page try: result = xref(typ, rawtext, text, lineno, inliner, options=options, content=content) except ReSTError, err: msg = inliner.reporter.error(str(err), line=lineno) return ([inliner.problematic(rawtext, rawtext, msg)], [msg])
def _ManPageRole( typ, rawtext, text, lineno, inliner, # pylint: disable=W0102 options={}, content=[]): """Custom role for man page references. Converts man pages to links if enabled during the build. """ xref = _ManPageXRefRole() assert ht.TNone(xref.converted) # Check if it's a known man page try: result = xref(typ, rawtext, text, lineno, inliner, options=options, content=content) except ReSTError as err: msg = inliner.reporter.error(str(err), line=lineno) return ([inliner.problematic(rawtext, rawtext, msg)], [msg]) assert ht.TBool(xref.converted) # Return if the conversion was successful (i.e. the man page was known and # conversion was enabled) if xref.converted: return result # Fallback if man page links are disabled or an unknown page is referenced return orig_manpage_role(typ, rawtext, text, lineno, inliner, options=options, content=content)