- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33.3k
          gh-93096: Make mimetypes 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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            68 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      494fba8
              
                Make mimetypes CLI tool public
              
              
                arhadthedev f7e288e
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev 5fdd909
              
                Add NEWS
              
              
                arhadthedev 1d778e2
              
                No other module names the entry point _cli
              
              
                arhadthedev d67704f
              
                Adjust tests (capitalization of "Usage:" changed)
              
              
                arhadthedev 55df248
              
                For CLI tests, make proper script invocations with proper checks
              
              
                arhadthedev b065ed8
              
                Address @AA-Turner's review
              
              
                arhadthedev e7db03d
              
                Move a constant check outside of a loop
              
              
                arhadthedev 6a1c96a
              
                Allow .pic MIME type be image/x-pict
              
              
                arhadthedev 010354d
              
                Follow PEP 8 more
              
              
                arhadthedev 3368be4
              
                Change forgotten quotation marks
              
              
                arhadthedev 26bec36
              
                Temporarily rollback everything but tests
              
              
                arhadthedev f1d4364
              
                Revert "Temporarily rollback everything but tests"
              
              
                arhadthedev 5e1de17
              
                Add comments about assertIn()
              
              
                arhadthedev e2ad463
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev 48f1746
              
                Normalize error codes too
              
              
                arhadthedev 11b067d
              
                `from sys import exit` clashes with the exit builtin
              
              
                arhadthedev 5589f7a
              
                Use f-strings for sys.exit()
              
              
                arhadthedev 3ade3a6
              
                Use an extension unknown to macOS
              
              
                arhadthedev 895ac27
              
                Fix an incorrect image/text to text/xul
              
              
                arhadthedev 4476b30
              
                Fix stdout/stderr mistesting
              
              
                arhadthedev 96e127b
              
                macOS, maybe Midi is what you don't override?
              
              
                arhadthedev 63b762e
              
                One more attempt to fix macOS-specific tests
              
              
                arhadthedev 543d003
              
                Maybe pict?
              
              
                arhadthedev 55c6165
              
                Skip the strict case where mime.types is used
              
              
                arhadthedev 54f9889
              
                Temporarily disable all test but the broken one
              
              
                arhadthedev be06897
              
                Temporarily remove doc building too
              
              
                arhadthedev 6af7668
              
                temporary: Add printing of a platform name
              
              
                arhadthedev 037b68e
              
                temporary: Another attempt
              
              
                arhadthedev de4f377
              
                Return to MIDI
              
              
                arhadthedev a8e7718
              
                Restore build scripts
              
              
                arhadthedev df910bc
              
                One more attempt
              
              
                arhadthedev cf2a768
              
                Fix a typo
              
              
                arhadthedev c975d4c
              
                Move a documentation-related news entry
              
              
                arhadthedev bc1c707
              
                Apply suggestions from the @AA-Turner's code review
              
              
                arhadthedev 1996d05
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev 2aec434
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev 9116a3d
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev 64297c0
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev aeba820
              
                Make CLI tests more strict
              
              
                arhadthedev c94593f
              
                Add newlines into assertEqual reference strings
              
              
                arhadthedev 8b20082
              
                Clarify the NEWS entries
              
              
                arhadthedev aa92570
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev ef15d7f
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev c942d89
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                arhadthedev 407413d
              
                Slightly reword documentation
              
              
                arhadthedev d58d5ba
              
                Reword the news entry
              
              
                arhadthedev 0cfe67e
              
                Add more examples
              
              
                arhadthedev d2797f0
              
                Clarify multi-input usage
              
              
                arhadthedev fd590f5
              
                Further rewording of the notes
              
              
                arhadthedev 1ef41dd
              
                Clarify data source
              
              
                arhadthedev 2797fc4
              
                Remove formatting-breaking "don't" from error messages
              
              
                arhadthedev 78c0c50
              
                Fix a grammar mistake
              
              
                arhadthedev 1afb6d6
              
                Make wording tighter
              
              
                arhadthedev a22d630
              
                Fix tests
              
              
                arhadthedev b9d5309
              
                Remove the command line input prefix
              
              
                arhadthedev f6e2e16
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                hugovk a9a43f7
              
                Fix tests
              
              
                hugovk 85727bf
              
                Fix test
              
              
                hugovk f1535fd
              
                Use console formatting for commands with output
              
              
                hugovk 8509c06
              
                Docs: default case first, put condition first, avoid Latin, adjust wo…
              
              
                hugovk 9ad283c
              
                Use long options in examples so no need to refer back to usage
              
              
                hugovk a2c0d53
              
                Follow argparse docs and use 'args'
              
              
                hugovk 34e0591
              
                Add to What's New, combine NEWS files, update reference, use sentence…
              
              
                hugovk 80e1734
              
                Hyphen
              
              
                hugovk 7cb62c5
              
                Update error message
              
              
                hugovk e23949a
              
                Merge branch 'main' into normalize-mimetypes-cli
              
              
                hugovk ce6999f
              
                Merge remote-tracking branch 'upstream/main' into normalize-mimetypes…
              
              
                hugovk File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
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
    
  
  
    
              
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
              
        
          
          
            5 changes: 5 additions & 0 deletions
          
          5 
        
  Misc/NEWS.d/next/Library/2022-05-28-19-41-02.gh-issue-93096.qjUyRG.rst
  
  
      
      
   
        
      
      
    
  
    
      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 | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Document the command-line for :mod:`mimetypes`. | ||
| It now exits with ``1`` on failure instead of ``0`` | ||
| and ``2`` on incorrect command-line parameters instead of ``1``. | ||
| Also, errors are printed to stderr instead of stdout and their text is made | ||
| tighter. Patch by Oleg Iarygin and Hugo van Kemenade. | 
      
      Oops, something went wrong.
        
    
  
  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.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some samples have
$prefix, some don't. I propose to remove all of them.Grep for
$ python, you won't find many examples.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right,
Doc/libraryinmainhas 14 prefixed submodule calls vs 18 non-prefixed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for me, it looks confusing (like some config file). Any ideas on what to do next?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A side question: is there a point to use
.. code-block:: shell-sessioninstead, as insite?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know :)
This is the first time I see this directive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general rule:
shellorshell-sessionorshconsoleFor example, here's how Markdown does it, which isn't identical to RST but close enough.
sh# get a MIME type by a file name python -m mimetypes filename.png type: image/png encoding: None$ # get a MIME type by a file name $ python -m mimetypes filename.png type: image/png encoding: NoneconsoleUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concretely, this:
gives:

And this:
gives:

I've pushed an update.