Generic interface to the inspector system. This function is meant to be called by pdef, pdoc & friends.
(self, meth, oname: str, namespaces=None, **kw)
| 1870 | return self._ofind(oname, namespaces) |
| 1871 | |
| 1872 | def _inspect(self, meth, oname: str, namespaces=None, **kw): |
| 1873 | """Generic interface to the inspector system. |
| 1874 | |
| 1875 | This function is meant to be called by pdef, pdoc & friends. |
| 1876 | """ |
| 1877 | info: OInfo = self._object_find(oname, namespaces) |
| 1878 | if self.sphinxify_docstring: |
| 1879 | if sphinxify is None: |
| 1880 | raise ImportError("Module ``docrepr`` required but missing") |
| 1881 | docformat = sphinxify(self.object_inspect(oname)) |
| 1882 | else: |
| 1883 | docformat = None |
| 1884 | if info.found or hasattr(info.parent, oinspect.HOOK_NAME): |
| 1885 | pmethod = getattr(self.inspector, meth) |
| 1886 | # TODO: only apply format_screen to the plain/text repr of the mime |
| 1887 | # bundle. |
| 1888 | formatter = format_screen if info.ismagic else docformat |
| 1889 | if meth == 'pdoc': |
| 1890 | pmethod(info.obj, oname, formatter) |
| 1891 | elif meth == 'pinfo': |
| 1892 | pmethod( |
| 1893 | info.obj, |
| 1894 | oname, |
| 1895 | formatter, |
| 1896 | info, |
| 1897 | enable_html_pager=self.enable_html_pager, |
| 1898 | **kw, |
| 1899 | ) |
| 1900 | else: |
| 1901 | pmethod(info.obj, oname) |
| 1902 | else: |
| 1903 | print('Object `%s` not found.' % oname) |
| 1904 | return 'not found' # so callers can take other action |
| 1905 | |
| 1906 | def object_inspect(self, oname, detail_level=0): |
| 1907 | """Get object info about oname""" |