Compute a dict with detailed information about an object. Parameters ---------- obj : any An object to find information about oname : str (default: '') Name of the variable pointing to `obj`. info : (default: None) A struct
(self, obj, oname="", info=None, detail_level=0)
| 852 | page.page(info_b) |
| 853 | |
| 854 | def info(self, obj, oname="", info=None, detail_level=0) -> InfoDict: |
| 855 | """Compute a dict with detailed information about an object. |
| 856 | |
| 857 | Parameters |
| 858 | ---------- |
| 859 | obj : any |
| 860 | An object to find information about |
| 861 | oname : str (default: '') |
| 862 | Name of the variable pointing to `obj`. |
| 863 | info : (default: None) |
| 864 | A struct (dict like with attr access) with some information fields |
| 865 | which may have been precomputed already. |
| 866 | detail_level : int (default:0) |
| 867 | If set to 1, more information is given. |
| 868 | |
| 869 | Returns |
| 870 | ------- |
| 871 | An object info dict with known fields from `info_fields` (see `InfoDict`). |
| 872 | """ |
| 873 | |
| 874 | if info is None: |
| 875 | ismagic = False |
| 876 | isalias = False |
| 877 | ospace = '' |
| 878 | else: |
| 879 | ismagic = info.ismagic |
| 880 | isalias = info.isalias |
| 881 | ospace = info.namespace |
| 882 | |
| 883 | # Get docstring, special-casing aliases: |
| 884 | att_name = oname.split(".")[-1] |
| 885 | parents_docs = None |
| 886 | prelude = "" |
| 887 | if info and info.parent is not None and hasattr(info.parent, HOOK_NAME): |
| 888 | parents_docs_dict = getattr(info.parent, HOOK_NAME) |
| 889 | if isinstance(parents_docs_dict, dict): |
| 890 | parents_docs = parents_docs_dict.get(att_name, None) |
| 891 | out: InfoDict = cast( |
| 892 | InfoDict, |
| 893 | { |
| 894 | **{field: None for field in _info_fields}, |
| 895 | **{ |
| 896 | "name": oname, |
| 897 | "found": True, |
| 898 | "isalias": isalias, |
| 899 | "ismagic": ismagic, |
| 900 | "subclasses": None, |
| 901 | }, |
| 902 | }, |
| 903 | ) |
| 904 | |
| 905 | if parents_docs: |
| 906 | ds = parents_docs |
| 907 | elif isalias: |
| 908 | if not callable(obj): |
| 909 | try: |
| 910 | ds = "Alias to the system command:\n %s" % obj[1] |
| 911 | except: |