Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
hugovk merged 68 commits intopython:mainfromarhadthedev:normalize-mimetypes-cli
Mar 13, 2025
Merged
Changes from1 commit
Commits
Show all changes
68 commits
Select commitHold shift + click to select a range
494fba8
Make mimetypes CLI tool public
arhadthedevMar 24, 2022
f7e288e
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevMay 23, 2022
5fdd909
Add NEWS
arhadthedevMay 23, 2022
1d778e2
No other module names the entry point _cli
arhadthedevMay 23, 2022
d67704f
Adjust tests (capitalization of "Usage:" changed)
arhadthedevMay 23, 2022
55df248
For CLI tests, make proper script invocations with proper checks
arhadthedevMay 23, 2022
b065ed8
Address @AA-Turner's review
arhadthedevMay 24, 2022
e7db03d
Move a constant check outside of a loop
arhadthedevMay 24, 2022
6a1c96a
Allow .pic MIME type be image/x-pict
arhadthedevMay 26, 2022
010354d
Follow PEP 8 more
arhadthedevMay 26, 2022
3368be4
Change forgotten quotation marks
arhadthedevMay 28, 2022
26bec36
Temporarily rollback everything but tests
arhadthedevMay 28, 2022
f1d4364
Revert "Temporarily rollback everything but tests"
arhadthedevMay 28, 2022
5e1de17
Add comments about assertIn()
arhadthedevMay 28, 2022
e2ad463
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevMay 28, 2022
48f1746
Normalize error codes too
arhadthedevMay 28, 2022
11b067d
`from sys import exit` clashes with the exit builtin
arhadthedevMay 28, 2022
5589f7a
Use f-strings for sys.exit()
arhadthedevMay 28, 2022
3ade3a6
Use an extension unknown to macOS
arhadthedevMay 28, 2022
895ac27
Fix an incorrect image/text to text/xul
arhadthedevMay 28, 2022
4476b30
Fix stdout/stderr mistesting
arhadthedevMay 28, 2022
96e127b
macOS, maybe Midi is what you don't override?
arhadthedevMay 28, 2022
63b762e
One more attempt to fix macOS-specific tests
arhadthedevMay 28, 2022
543d003
Maybe pict?
arhadthedevMay 28, 2022
55c6165
Skip the strict case where mime.types is used
arhadthedevMay 28, 2022
54f9889
Temporarily disable all test but the broken one
arhadthedevMay 28, 2022
be06897
Temporarily remove doc building too
arhadthedevMay 28, 2022
6af7668
temporary: Add printing of a platform name
arhadthedevMay 28, 2022
037b68e
temporary: Another attempt
arhadthedevMay 28, 2022
de4f377
Return to MIDI
arhadthedevMay 28, 2022
a8e7718
Restore build scripts
arhadthedevMay 28, 2022
df910bc
One more attempt
arhadthedevMay 28, 2022
cf2a768
Fix a typo
arhadthedevMay 29, 2022
c975d4c
Move a documentation-related news entry
arhadthedevJun 2, 2022
bc1c707
Apply suggestions from the @AA-Turner's code review
arhadthedevJun 10, 2022
1996d05
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevJul 1, 2022
2aec434
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevJul 21, 2022
9116a3d
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevSep 25, 2022
64297c0
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevOct 25, 2022
aeba820
Make CLI tests more strict
arhadthedevOct 25, 2022
c94593f
Add newlines into assertEqual reference strings
arhadthedevOct 25, 2022
8b20082
Clarify the NEWS entries
arhadthedevOct 25, 2022
aa92570
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevOct 30, 2022
ef15d7f
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevNov 29, 2022
c942d89
Merge branch 'main' into normalize-mimetypes-cli
arhadthedevJan 24, 2023
407413d
Slightly reword documentation
arhadthedevJan 24, 2023
d58d5ba
Reword the news entry
arhadthedevJan 24, 2023
0cfe67e
Add more examples
arhadthedevJan 24, 2023
d2797f0
Clarify multi-input usage
arhadthedevJan 24, 2023
fd590f5
Further rewording of the notes
arhadthedevJan 24, 2023
1ef41dd
Clarify data source
arhadthedevJan 24, 2023
2797fc4
Remove formatting-breaking "don't" from error messages
arhadthedevJan 24, 2023
78c0c50
Fix a grammar mistake
arhadthedevJan 24, 2023
1afb6d6
Make wording tighter
arhadthedevJan 24, 2023
a22d630
Fix tests
arhadthedevJan 24, 2023
b9d5309
Remove the command line input prefix
arhadthedevJan 24, 2023
f6e2e16
Merge branch 'main' into normalize-mimetypes-cli
hugovkMar 7, 2025
a9a43f7
Fix tests
hugovkMar 7, 2025
85727bf
Fix test
hugovkMar 7, 2025
f1535fd
Use console formatting for commands with output
hugovkMar 7, 2025
8509c06
Docs: default case first, put condition first, avoid Latin, adjust wo…
hugovkMar 8, 2025
9ad283c
Use long options in examples so no need to refer back to usage
hugovkMar 8, 2025
a2c0d53
Follow argparse docs and use 'args'
hugovkMar 8, 2025
34e0591
Add to What's New, combine NEWS files, update reference, use sentence…
hugovkMar 8, 2025
80e1734
Hyphen
hugovkMar 8, 2025
7cb62c5
Update error message
hugovkMar 10, 2025
e23949a
Merge branch 'main' into normalize-mimetypes-cli
hugovkMar 10, 2025
ce6999f
Merge remote-tracking branch 'upstream/main' into normalize-mimetypes…
hugovkMar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Revert "Temporarily rollback everything but tests"
This reverts commit26bec36.
  • Loading branch information
@arhadthedev
arhadthedev committedMay 28, 2022
commitf1d4364a0cef130c2a7c97621e526f9e698cfcae
74 changes: 31 additions & 43 deletionsLib/mimetypes.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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',
Expand DownExpand Up@@ -589,6 +590,7 @@ def _default_mime_types():
'.pict': 'image/pict',
'.pct' : 'image/pict',
'.pic' : 'image/pict',
'.webp': 'image/webp',
'.xul' : 'text/xul',
}

Expand All@@ -597,49 +599,35 @@ def _default_mime_types():


def _main():
import getopt

USAGE = """\
Usage: mimetypes.py [options] type

Options:
--help / -h -- print this message and exit
--lenient / -l -- additionally search of some common, but non-standard
types.
--extension / -e -- guess extension instead of type

More than one type argument may be given.
"""

def usage(code, msg=''):
print(USAGE)
if msg: print(msg)
sys.exit(code)

try:
opts, args = getopt.getopt(sys.argv[1:], 'hle',
['help', 'lenient', 'extension'])
except getopt.error as msg:
usage(1, msg)

strict = 1
extension = 0
for opt, arg in opts:
if opt in ('-h', '--help'):
usage(0)
elif opt in ('-l', '--lenient'):
strict = 0
elif opt in ('-e', '--extension'):
extension = 1
for gtype in args:
if extension:
guess = guess_extension(gtype, strict)
if not guess: print("I don't know anything about type", gtype)
else: print(guess)
else:
guess, encoding = guess_type(gtype, strict)
if not guess: print("I don't know anything about type", gtype)
else: print('type:', guess, 'encoding:', encoding)
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'
)
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__':
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp