##// END OF EJS Templates
Merge pull request #13343 from fasiha/blocklist-for-info...
Matthias Bussonnier -
r27188:6d0095d2 merge
parent child Browse files
Show More
@@ -1699,7 +1699,7 b' class InteractiveShell(SingletonConfigurable):'
1699 """Get object info as formatted text"""
1699 """Get object info as formatted text"""
1700 return self.object_inspect_mime(oname, detail_level)['text/plain']
1700 return self.object_inspect_mime(oname, detail_level)['text/plain']
1701
1701
1702 def object_inspect_mime(self, oname, detail_level=0):
1702 def object_inspect_mime(self, oname, detail_level=0, omit_sections=()):
1703 """Get object info as a mimebundle of formatted representations.
1703 """Get object info as a mimebundle of formatted representations.
1704
1704
1705 A mimebundle is a dictionary, keyed by mime-type.
1705 A mimebundle is a dictionary, keyed by mime-type.
@@ -1715,6 +1715,7 b' class InteractiveShell(SingletonConfigurable):'
1715 info=info,
1715 info=info,
1716 detail_level=detail_level,
1716 detail_level=detail_level,
1717 formatter=docformat,
1717 formatter=docformat,
1718 omit_sections=omit_sections,
1718 )
1719 )
1719 else:
1720 else:
1720 raise KeyError(oname)
1721 raise KeyError(oname)
@@ -566,7 +566,9 b' class Inspector(Colorable):'
566 bundle['text/plain'] = text
566 bundle['text/plain'] = text
567 return bundle
567 return bundle
568
568
569 def _get_info(self, obj, oname='', formatter=None, info=None, detail_level=0):
569 def _get_info(
570 self, obj, oname="", formatter=None, info=None, detail_level=0, omit_sections=()
571 ):
570 """Retrieve an info dict and format it.
572 """Retrieve an info dict and format it.
571
573
572 Parameters
574 Parameters
@@ -581,6 +583,8 b' class Inspector(Colorable):'
581 already computed information
583 already computed information
582 detail_level: integer
584 detail_level: integer
583 Granularity of detail level, if set to 1, give more information.
585 Granularity of detail level, if set to 1, give more information.
586 omit_sections: container[str]
587 Titles or keys to omit from output (can be set, tuple, etc., anything supporting `in`)
584 """
588 """
585
589
586 info = self._info(obj, oname=oname, info=info, detail_level=detail_level)
590 info = self._info(obj, oname=oname, info=info, detail_level=detail_level)
@@ -591,6 +595,8 b' class Inspector(Colorable):'
591 }
595 }
592
596
593 def append_field(bundle, title:str, key:str, formatter=None):
597 def append_field(bundle, title:str, key:str, formatter=None):
598 if title in omit_sections or key in omit_sections:
599 return
594 field = info[key]
600 field = info[key]
595 if field is not None:
601 if field is not None:
596 formatted_field = self._mime_format(field, formatter)
602 formatted_field = self._mime_format(field, formatter)
@@ -655,7 +661,16 b' class Inspector(Colorable):'
655
661
656 return self.format_mime(_mime)
662 return self.format_mime(_mime)
657
663
658 def pinfo(self, obj, oname='', formatter=None, info=None, detail_level=0, enable_html_pager=True):
664 def pinfo(
665 self,
666 obj,
667 oname="",
668 formatter=None,
669 info=None,
670 detail_level=0,
671 enable_html_pager=True,
672 omit_sections=(),
673 ):
659 """Show detailed information about an object.
674 """Show detailed information about an object.
660
675
661 Optional arguments:
676 Optional arguments:
@@ -676,8 +691,12 b' class Inspector(Colorable):'
676 precomputed already.
691 precomputed already.
677
692
678 - detail_level: if set to 1, more information is given.
693 - detail_level: if set to 1, more information is given.
694
695 - omit_sections: set of section keys and titles to omit
679 """
696 """
680 info = self._get_info(obj, oname, formatter, info, detail_level)
697 info = self._get_info(
698 obj, oname, formatter, info, detail_level, omit_sections=omit_sections
699 )
681 if not enable_html_pager:
700 if not enable_html_pager:
682 del info['text/html']
701 del info['text/html']
683 page.page(info)
702 page.page(info)
General Comments 0
You need to be logged in to leave comments. Login now