Run the mimetypes command-line interface and return a text to print.
(args=None)
| 726 | |
| 727 | |
| 728 | def _main(args=None): |
| 729 | """Run the mimetypes command-line interface and return a text to print.""" |
| 730 | args, help_text = _parse_args(args) |
| 731 | |
| 732 | results = [] |
| 733 | if args.extension: |
| 734 | for gtype in args.type: |
| 735 | guess = guess_extension(gtype, not args.lenient) |
| 736 | if guess: |
| 737 | results.append(str(guess)) |
| 738 | else: |
| 739 | results.append(f"error: unknown type {gtype}") |
| 740 | return results |
| 741 | else: |
| 742 | for gtype in args.type: |
| 743 | guess, encoding = guess_type(gtype, not args.lenient) |
| 744 | if guess: |
| 745 | results.append(f"type: {guess} encoding: {encoding}") |
| 746 | else: |
| 747 | results.append(f"error: media type unknown for {gtype}") |
| 748 | return results |
| 749 | |
| 750 | |
| 751 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…