Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
51cc3bcd
Kaydet (Commit)
51cc3bcd
authored
Şub 09, 2001
tarafından
Eric S. Raymond
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
String method conversion. Added a trivial main to test it with.
üst
ec3bbdef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
mimetypes.py
Lib/mimetypes.py
+10
-7
No files found.
Lib/mimetypes.py
Dosyayı görüntüle @
51cc3bcd
...
@@ -23,7 +23,6 @@ read_mime_types(file) -- parse one file, return a dictionary or None
...
@@ -23,7 +23,6 @@ read_mime_types(file) -- parse one file, return a dictionary or None
"""
"""
import
string
import
posixpath
import
posixpath
import
urllib
import
urllib
...
@@ -64,11 +63,11 @@ def guess_type(url):
...
@@ -64,11 +63,11 @@ def guess_type(url):
# data := *urlchar
# data := *urlchar
# parameter := attribute "=" value
# parameter := attribute "=" value
# type/subtype defaults to "text/plain"
# type/subtype defaults to "text/plain"
comma
=
string
.
find
(
url
,
','
)
comma
=
url
.
find
(
','
)
if
comma
<
0
:
if
comma
<
0
:
# bad data URL
# bad data URL
return
None
,
None
return
None
,
None
semi
=
string
.
find
(
url
,
';'
,
0
,
comma
)
semi
=
url
.
find
(
';'
,
0
,
comma
)
if
semi
>=
0
:
if
semi
>=
0
:
type
=
url
[:
semi
]
type
=
url
[:
semi
]
else
:
else
:
...
@@ -86,8 +85,8 @@ def guess_type(url):
...
@@ -86,8 +85,8 @@ def guess_type(url):
encoding
=
None
encoding
=
None
if
types_map
.
has_key
(
ext
):
if
types_map
.
has_key
(
ext
):
return
types_map
[
ext
],
encoding
return
types_map
[
ext
],
encoding
elif
types_map
.
has_key
(
string
.
lower
(
ext
)):
elif
types_map
.
has_key
(
ext
.
lower
(
)):
return
types_map
[
string
.
lower
(
ext
)],
encoding
return
types_map
[
ext
.
lower
(
)],
encoding
else
:
else
:
return
None
,
encoding
return
None
,
encoding
...
@@ -103,7 +102,7 @@ def guess_extension(type):
...
@@ -103,7 +102,7 @@ def guess_extension(type):
global
inited
global
inited
if
not
inited
:
if
not
inited
:
init
()
init
()
type
=
string
.
lower
(
type
)
type
=
type
.
lower
(
)
for
ext
,
stype
in
types_map
.
items
():
for
ext
,
stype
in
types_map
.
items
():
if
type
==
stype
:
if
type
==
stype
:
return
ext
return
ext
...
@@ -127,7 +126,7 @@ def read_mime_types(file):
...
@@ -127,7 +126,7 @@ def read_mime_types(file):
while
1
:
while
1
:
line
=
f
.
readline
()
line
=
f
.
readline
()
if
not
line
:
break
if
not
line
:
break
words
=
string
.
split
(
line
)
words
=
line
.
split
(
)
for
i
in
range
(
len
(
words
)):
for
i
in
range
(
len
(
words
)):
if
words
[
i
][
0
]
==
'#'
:
if
words
[
i
][
0
]
==
'#'
:
del
words
[
i
:]
del
words
[
i
:]
...
@@ -237,3 +236,7 @@ types_map = {
...
@@ -237,3 +236,7 @@ types_map = {
'.xwd'
:
'image/x-xwindowdump'
,
'.xwd'
:
'image/x-xwindowdump'
,
'.zip'
:
'application/zip'
,
'.zip'
:
'application/zip'
,
}
}
if
__name__
==
'__main__'
:
import
sys
print
guess_type
(
sys
.
argv
[
1
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment