MCPcopy Index your code
hub / github.com/python/cpython / _main

Function _main

Lib/mimetypes.py:728–748  ·  view source on GitHub ↗

Run the mimetypes command-line interface and return a text to print.

(args=None)

Source from the content-addressed store, hash-verified

726
727
728def _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
751if __name__ == '__main__':

Callers 1

mimetypes.pyFile · 0.70

Calls 5

guess_extensionFunction · 0.85
strFunction · 0.85
guess_typeFunction · 0.85
_parse_argsFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…