GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-93096: Make `mimetypes` CLI tool public by arhadthedev · Pull Request #93097 · python/cpython

Conversation

@arhadthedev

@arhadthedev arhadthedev commented May 23, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Document python -m mimetypes (like https://docs.python.org/3/library/ast.html#command-line-usage and https://docs.python.org/3/library/trace.html#command-line-usage do) since it's a solid crossplatform utility
  • replace getopt with argparse for unified help text and error messages
  • use sys.exit() for error messages
  • make tests to call python -m mimetypes with proper checks of stdout, stderr and return codes

gh-93096

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
arhadthedev added 3 commits May 23, 2022 11:58
@arhadthedev
Make mimetypes CLI tool public
494fba8
@arhadthedev
Merge branch 'main' into normalize-mimetypes-cli
f7e288e
@arhadthedev
Add NEWS
5fdd909
@arhadthedev
arhadthedev requested a review from a team as a code owner May 23, 2022 09:05
@bedevere-bot bedevere-bot added the awaiting review label May 23, 2022
@arhadthedev
No other module names the entry point _cli
1d778e2
@arhadthedev
arhadthedev marked this pull request as draft May 23, 2022 10:43
arhadthedev added 2 commits May 23, 2022 16:29
@arhadthedev
Adjust tests (capitalization of "Usage:" changed)
d67704f
@arhadthedev
For CLI tests, make proper script invocations with proper checks
55df248
@arhadthedev
arhadthedev marked this pull request as ready for review May 23, 2022 15:45
@arhadthedev
arhadthedev marked this pull request as draft May 23, 2022 17:14
AA-Turner
AA-Turner reviewed May 23, 2022
View reviewed changes
Comment thread Lib/mimetypes.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/mimetypes.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@AA-Turner AA-Turner added type-feature A feature request or enhancement stdlib Standard Library Python modules in the Lib/ directory topic-email labels May 23, 2022
arhadthedev added 2 commits May 24, 2022 13:01
@arhadthedev
Address @AA-Turner's review
b065ed8
@arhadthedev
Move a constant check outside of a loop
e7db03d
arhadthedev
arhadthedev commented May 24, 2022
View reviewed changes
Comment thread Lib/test/test_mimetypes.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@arhadthedev arhadthedev closed this May 26, 2022
@arhadthedev
arhadthedev deleted the normalize-mimetypes-cli branch May 26, 2022 05:12
@arhadthedev
arhadthedev restored the normalize-mimetypes-cli branch May 26, 2022 05:13
@arhadthedev arhadthedev reopened this May 26, 2022
arhadthedev added 8 commits May 26, 2022 08:16
@arhadthedev
Allow .pic MIME type be image/x-pict
6a1c96a
@arhadthedev
Follow PEP 8 more
010354d
@arhadthedev
Change forgotten quotation marks
3368be4
@arhadthedev
Temporarily rollback everything but tests
26bec36
@arhadthedev
Revert "Temporarily rollback everything but tests"
f1d4364
This reverts commit 26bec36.
@arhadthedev
Add comments about assertIn()
5e1de17
@arhadthedev
Merge branch 'main' into normalize-mimetypes-cli
e2ad463
@arhadthedev
Normalize error codes too
48f1746
@sobolevn

sobolevn commented Feb 7, 2024

Copy link
Copy Markdown
Member

@arhadthedev do you have time to finish it any time soon? :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maxnikulin

maxnikulin commented Feb 7, 2024

Copy link
Copy Markdown

Notice that IANA currently uses the "media types" term:

[RFC2046] specifies that Media Types (formerly known as MIME types) and Media
Subtypes will be assigned and listed by the IANA.

Just an idea, feel free to ignore it: sometimes the following approach may be used to estimate --help message. Try to read man page generated by help2man. Perhaps epilog may be added to ArgumentParser constructor, however I am unsure concerning recommendations within the Python project.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

hugovk added 9 commits March 7, 2025 15:02
@hugovk
Merge branch 'main' into normalize-mimetypes-cli
f6e2e16
@hugovk
Fix tests
a9a43f7
@hugovk
Fix test
85727bf
@hugovk
Use console formatting for commands with output
f1535fd
@hugovk
Docs: default case first, put condition first, avoid Latin, adjust wo…
8509c06
…rding
@hugovk
Use long options in examples so no need to refer back to usage
9ad283c
@hugovk
Follow argparse docs and use 'args'
a2c0d53
@hugovk
Add to What's New, combine NEWS files, update reference, use sentence…
34e0591
… case

https://devguide.python.org/documentation/style-guide/\#capitalization
@hugovk
Hyphen
80e1734
@hugovk
hugovk marked this pull request as ready for review March 8, 2025 21:06
@bedevere-app bedevere-app Bot added awaiting review and removed awaiting core review labels Mar 8, 2025
hugovk
hugovk approved these changes Mar 8, 2025
View reviewed changes

@hugovk hugovk left a comment

Copy link
Copy Markdown
Member

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.

@arhadthedev Thank you for your work!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Mar 8, 2025
merwok
merwok reviewed Mar 10, 2025
View reviewed changes
Comment thread Lib/mimetypes.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

hugovk
hugovk reviewed Mar 10, 2025
View reviewed changes
Comment thread Lib/test/test_mimetypes.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

hugovk added 3 commits March 11, 2025 00:31
@hugovk
Update error message
7cb62c5
@hugovk
Merge branch 'main' into normalize-mimetypes-cli
e23949a
@hugovk
Merge remote-tracking branch 'upstream/main' into normalize-mimetypes…
ce6999f
…-cli
@hugovk
hugovk merged commit 328f8b8 into python:main Mar 13, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 13, 2025
@picnixz

picnixz commented Mar 15, 2025

Copy link
Copy Markdown
Member

Not sure if it's my configuration or not, but test_guess_type_conflicting_with_mimetypes fails on my openSUSE 15.5. I think the reason is that my /etc/mime.types contains:

image/x-pict                                     pict pict1 pict2 pic pct
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Mar 15, 2025

Copy link
Copy Markdown
Member

Right, from the commits looks like it took a while for @arhadthedev to find a good candidate. Let's update it.

@picnixz Can you find another that's not in your /etc/mime.types?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@picnixz

picnixz commented Mar 15, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I'm no more on my Linux session, but I'll do it tomorrow. Can't we mock the array containing the files where everything is looked up?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hugovk

hugovk commented Mar 15, 2025

Copy link
Copy Markdown
Member

Yes, that sounds better than having to worry what different systems happen to have.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

plashchynski pushed a commit to plashchynski/cpython that referenced this pull request Mar 17, 2025
@arhadthedev @AA-Turner
@hugovk @plashchynski
pythongh-93096: Make mimetypes CLI tool public (python#93097)
6531d62
Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
@picnixz picnixz mentioned this pull request Mar 18, 2025
gh-93096: fix test_mimetypes.test_guess_type_conflicting_with_mimetypes #131408
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merwok merwok merwok left review comments
@hugovk hugovk hugovk approved these changes
@sobolevn sobolevn sobolevn left review comments
@AA-Turner AA-Turner AA-Turner approved these changes
+1 more reviewer
@carlbordum carlbordum carlbordum left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stdlib Standard Library Python modules in the Lib/ directory topic-email type-feature A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@arhadthedev @AA-Turner @sobolevn @maxnikulin @picnixz @hugovk @merwok @carlbordum @bedevere-bot
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.