Show More
@@ -553,23 +553,23 b' class Inspector(Colorable):' | |||||
553 |
|
553 | |||
554 | def format_mime(self, bundle): |
|
554 | def format_mime(self, bundle): | |
555 | """Format a mimebundle being created by _make_info_unformatted into a real mimebundle""" |
|
555 | """Format a mimebundle being created by _make_info_unformatted into a real mimebundle""" | |
556 | # First, format the field names and values for the text/plain field |
|
556 | # Format text/plain mimetype | |
557 |
|
|
557 | if isinstance(bundle['text/plain'], (list, tuple)): | |
558 | if isinstance(text_plain, (list, tuple)): |
|
558 | # bundle['text/plain'] is a list of (head, formatted body) pairs | |
559 |
|
|
559 | lines = [] | |
560 | heads, bodies = list(zip(*text_plain)) |
|
560 | _len = max(len(h) for h,_ in bundle['text/plain']) | |
561 | _len = max(len(h) for h in heads) |
|
561 | ||
562 |
|
562 | for head, body in bundle['text/plain']: | ||
563 | for head, body in zip(heads, bodies): |
|
|||
564 | body = body.strip('\n') |
|
563 | body = body.strip('\n') | |
565 | delim = '\n' if '\n' in body else ' ' |
|
564 | delim = '\n' if '\n' in body else ' ' | |
566 |
|
|
565 | lines.append(f"{self.__head(head+':')}{(_len - len(head))*' '}{delim}{body}") | |
567 |
|
566 | |||
568 |
bundle['text/plain'] = |
|
567 | bundle['text/plain'] = '\n'.join(lines) | |
569 |
|
568 | |||
570 | # Next format the text/html value by joining strings if it is a list of strings |
|
569 | # Format the text/html mimetype | |
571 | if isinstance(bundle['text/html'], (list, tuple)): |
|
570 | if isinstance(bundle['text/html'], (list, tuple)): | |
572 | bundle['text/html'] = '\n'.join(bundle['text/html']) |
|
571 | # bundle['text/html'] is a list of (head, formatted body) pairs | |
|
572 | bundle['text/html'] = '\n'.join((f'<h1>{head}</h1>\n{body}' for (head,body) in bundle['text/html'])) | |||
573 | return bundle |
|
573 | return bundle | |
574 |
|
574 | |||
575 | def _append_info_field(self, bundle, title:str, key:str, info, omit_sections, formatter): |
|
575 | def _append_info_field(self, bundle, title:str, key:str, info, omit_sections, formatter): | |
@@ -580,7 +580,7 b' class Inspector(Colorable):' | |||||
580 | if field is not None: |
|
580 | if field is not None: | |
581 | formatted_field = self._mime_format(field, formatter) |
|
581 | formatted_field = self._mime_format(field, formatter) | |
582 | bundle['text/plain'].append((title, formatted_field['text/plain'])) |
|
582 | bundle['text/plain'].append((title, formatted_field['text/plain'])) | |
583 |
bundle['text/html'] |
|
583 | bundle['text/html'].append((title, formatted_field['text/html'])) | |
584 |
|
584 | |||
585 | def _make_info_unformatted(self, info, formatter, detail_level, omit_sections): |
|
585 | def _make_info_unformatted(self, info, formatter, detail_level, omit_sections): | |
586 | """Assemble the mimebundle as unformatted lists of information""" |
|
586 | """Assemble the mimebundle as unformatted lists of information""" |
General Comments 0
You need to be logged in to leave comments.
Login now