Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
gh-93096: Makemimetypes
CLI tool public#93097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
68 commits Select commitHold shift + click to select a range
494fba8
Make mimetypes CLI tool public
arhadthedevf7e288e
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev5fdd909
Add NEWS
arhadthedev1d778e2
No other module names the entry point _cli
arhadthedevd67704f
Adjust tests (capitalization of "Usage:" changed)
arhadthedev55df248
For CLI tests, make proper script invocations with proper checks
arhadthedevb065ed8
Address @AA-Turner's review
arhadthedeve7db03d
Move a constant check outside of a loop
arhadthedev6a1c96a
Allow .pic MIME type be image/x-pict
arhadthedev010354d
Follow PEP 8 more
arhadthedev3368be4
Change forgotten quotation marks
arhadthedev26bec36
Temporarily rollback everything but tests
arhadthedevf1d4364
Revert "Temporarily rollback everything but tests"
arhadthedev5e1de17
Add comments about assertIn()
arhadthedeve2ad463
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev48f1746
Normalize error codes too
arhadthedev11b067d
`from sys import exit` clashes with the exit builtin
arhadthedev5589f7a
Use f-strings for sys.exit()
arhadthedev3ade3a6
Use an extension unknown to macOS
arhadthedev895ac27
Fix an incorrect image/text to text/xul
arhadthedev4476b30
Fix stdout/stderr mistesting
arhadthedev96e127b
macOS, maybe Midi is what you don't override?
arhadthedev63b762e
One more attempt to fix macOS-specific tests
arhadthedev543d003
Maybe pict?
arhadthedev55c6165
Skip the strict case where mime.types is used
arhadthedev54f9889
Temporarily disable all test but the broken one
arhadthedevbe06897
Temporarily remove doc building too
arhadthedev6af7668
temporary: Add printing of a platform name
arhadthedev037b68e
temporary: Another attempt
arhadthedevde4f377
Return to MIDI
arhadthedeva8e7718
Restore build scripts
arhadthedevdf910bc
One more attempt
arhadthedevcf2a768
Fix a typo
arhadthedevc975d4c
Move a documentation-related news entry
arhadthedevbc1c707
Apply suggestions from the @AA-Turner's code review
arhadthedev1996d05
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev2aec434
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev9116a3d
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev64297c0
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevaeba820
Make CLI tests more strict
arhadthedevc94593f
Add newlines into assertEqual reference strings
arhadthedev8b20082
Clarify the NEWS entries
arhadthedevaa92570
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevef15d7f
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevc942d89
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev407413d
Slightly reword documentation
arhadthedevd58d5ba
Reword the news entry
arhadthedev0cfe67e
Add more examples
arhadthedevd2797f0
Clarify multi-input usage
arhadthedevfd590f5
Further rewording of the notes
arhadthedev1ef41dd
Clarify data source
arhadthedev2797fc4
Remove formatting-breaking "don't" from error messages
arhadthedev78c0c50
Fix a grammar mistake
arhadthedev1afb6d6
Make wording tighter
arhadthedeva22d630
Fix tests
arhadthedevb9d5309
Remove the command line input prefix
arhadthedevf6e2e16
Merge branch 'main' into normalize-mimetypes-cli
hugovka9a43f7
Fix tests
hugovk85727bf
Fix test
hugovkf1535fd
Use console formatting for commands with output
hugovk8509c06
Docs: default case first, put condition first, avoid Latin, adjust wo…
hugovk9ad283c
Use long options in examples so no need to refer back to usage
hugovka2c0d53
Follow argparse docs and use 'args'
hugovk34e0591
Add to What's New, combine NEWS files, update reference, use sentence…
hugovk80e1734
Hyphen
hugovk7cb62c5
Update error message
hugovke23949a
Merge branch 'main' into normalize-mimetypes-cli
hugovkce6999f
Merge remote-tracking branch 'upstream/main' into normalize-mimetypes…
hugovkFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Revert "Temporarily rollback everything but tests"
This reverts commit26bec36.
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitf1d4364a0cef130c2a7c97621e526f9e698cfcae
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -517,6 +517,7 @@ def _default_mime_types(): | ||
'.aiff' : 'audio/x-aiff', | ||
'.ra' : 'audio/x-pn-realaudio', | ||
'.wav' : 'audio/x-wav', | ||
'.avif' : 'image/avif', | ||
'.bmp' : 'image/bmp', | ||
'.gif' : 'image/gif', | ||
'.ief' : 'image/ief', | ||
@@ -589,6 +590,7 @@ def _default_mime_types(): | ||
'.pict': 'image/pict', | ||
'.pct' : 'image/pict', | ||
'.pic' : 'image/pict', | ||
'.webp': 'image/webp', | ||
'.xul' : 'text/xul', | ||
} | ||
@@ -597,49 +599,35 @@ def _default_mime_types(): | ||
def _main(): | ||
from argparse import ArgumentParser | ||
parser = ArgumentParser(description='map filename extensions to MIME types') | ||
parser.add_argument( | ||
'-e', '--extension', | ||
action='store_true', | ||
help='guess extension instead of type' | ||
) | ||
parser.add_argument( | ||
'-l', '--lenient', | ||
action='store_true', | ||
help='additianally search for common but non-standard types' | ||
arhadthedev marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
) | ||
parser.add_argument('type', nargs='+', help='a type to search') | ||
arguments = parser.parse_args() | ||
if arguments.extension: | ||
for gtype in arguments.type: | ||
guess = guess_extension(gtype, not arguments.lenient) | ||
if guess: | ||
print(guess) | ||
else: | ||
print("I don't know anything about type", gtype) | ||
else: | ||
for gtype in arguments.type: | ||
guess, encoding = guess_type(gtype, not arguments.lenient) | ||
if guess: | ||
print('type:', guess, 'encoding:', encoding) | ||
else: | ||
print("I don't know anything about type", gtype) | ||
if __name__ == '__main__': | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.