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
1c5fb1cd
Kaydet (Commit)
1c5fb1cd
authored
Eki 12, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make mimetypes.guess_type understand data URLs. (Sjoerd Mullender)
üst
8571ed86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
mimetypes.py
Lib/mimetypes.py
+21
-0
No files found.
Lib/mimetypes.py
Dosyayı görüntüle @
1c5fb1cd
...
@@ -25,6 +25,7 @@ read_mime_types(file) -- parse one file, return a dictionary or None
...
@@ -25,6 +25,7 @@ read_mime_types(file) -- parse one file, return a dictionary or None
import
string
import
string
import
posixpath
import
posixpath
import
urllib
knownfiles
=
[
knownfiles
=
[
"/usr/local/etc/httpd/conf/mime.types"
,
"/usr/local/etc/httpd/conf/mime.types"
,
...
@@ -53,6 +54,26 @@ def guess_type(url):
...
@@ -53,6 +54,26 @@ def guess_type(url):
"""
"""
if
not
inited
:
if
not
inited
:
init
()
init
()
scheme
,
url
=
urllib
.
splittype
(
url
)
if
scheme
==
'data'
:
# syntax of data URLs:
# dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
# mediatype := [ type "/" subtype ] *( ";" parameter )
# data := *urlchar
# parameter := attribute "=" value
# type/subtype defaults to "text/plain"
comma
=
string
.
find
(
url
,
','
)
if
comma
<
0
:
# bad data URL
return
None
,
None
semi
=
string
.
find
(
url
,
';'
,
0
,
comma
)
if
semi
>=
0
:
type
=
url
[:
semi
]
else
:
type
=
url
[:
comma
]
if
'='
in
type
or
'/'
not
in
type
:
type
=
'text/plain'
return
type
,
None
# never compressed, so encoding is None
base
,
ext
=
posixpath
.
splitext
(
url
)
base
,
ext
=
posixpath
.
splitext
(
url
)
while
suffix_map
.
has_key
(
ext
):
while
suffix_map
.
has_key
(
ext
):
base
,
ext
=
posixpath
.
splitext
(
base
+
suffix_map
[
ext
])
base
,
ext
=
posixpath
.
splitext
(
base
+
suffix_map
[
ext
])
...
...
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