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
0c03cc20
Kaydet (Commit)
0c03cc20
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.
üst
bf97c9d8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
mailcap.py
Lib/mailcap.py
+12
-13
No files found.
Lib/mailcap.py
Dosyayı görüntüle @
0c03cc20
"""Mailcap file handling. See RFC 1524."""
"""Mailcap file handling. See RFC 1524."""
import
os
import
os
import
string
__all__
=
[
"getcaps"
,
"findmatch"
]
__all__
=
[
"getcaps"
,
"findmatch"
]
...
@@ -37,7 +36,7 @@ def listmailcapfiles():
...
@@ -37,7 +36,7 @@ def listmailcapfiles():
# XXX Actually, this is Unix-specific
# XXX Actually, this is Unix-specific
if
os
.
environ
.
has_key
(
'MAILCAPS'
):
if
os
.
environ
.
has_key
(
'MAILCAPS'
):
str
=
os
.
environ
[
'MAILCAPS'
]
str
=
os
.
environ
[
'MAILCAPS'
]
mailcaps
=
str
ing
.
splitfields
(
str
,
':'
)
mailcaps
=
str
.
split
(
':'
)
else
:
else
:
if
os
.
environ
.
has_key
(
'HOME'
):
if
os
.
environ
.
has_key
(
'HOME'
):
home
=
os
.
environ
[
'HOME'
]
home
=
os
.
environ
[
'HOME'
]
...
@@ -65,7 +64,7 @@ def readmailcapfile(fp):
...
@@ -65,7 +64,7 @@ def readmailcapfile(fp):
line
=
fp
.
readline
()
line
=
fp
.
readline
()
if
not
line
:
break
if
not
line
:
break
# Ignore comments and blank lines
# Ignore comments and blank lines
if
line
[
0
]
==
'#'
or
string
.
strip
(
line
)
==
''
:
if
line
[
0
]
==
'#'
or
line
.
strip
(
)
==
''
:
continue
continue
nextline
=
line
nextline
=
line
# Join continuation lines
# Join continuation lines
...
@@ -78,10 +77,10 @@ def readmailcapfile(fp):
...
@@ -78,10 +77,10 @@ def readmailcapfile(fp):
if
not
(
key
and
fields
):
if
not
(
key
and
fields
):
continue
continue
# Normalize the key
# Normalize the key
types
=
string
.
splitfields
(
key
,
'/'
)
types
=
key
.
split
(
'/'
)
for
j
in
range
(
len
(
types
)):
for
j
in
range
(
len
(
types
)):
types
[
j
]
=
string
.
strip
(
types
[
j
]
)
types
[
j
]
=
types
[
j
]
.
strip
(
)
key
=
string
.
lower
(
string
.
joinfields
(
types
,
'/'
)
)
key
=
'/'
.
join
(
types
)
.
lower
(
)
# Update the database
# Update the database
if
caps
.
has_key
(
key
):
if
caps
.
has_key
(
key
):
caps
[
key
]
.
append
(
fields
)
caps
[
key
]
.
append
(
fields
)
...
@@ -106,13 +105,13 @@ def parseline(line):
...
@@ -106,13 +105,13 @@ def parseline(line):
key
,
view
,
rest
=
fields
[
0
],
fields
[
1
],
fields
[
2
:]
key
,
view
,
rest
=
fields
[
0
],
fields
[
1
],
fields
[
2
:]
fields
=
{
'view'
:
view
}
fields
=
{
'view'
:
view
}
for
field
in
rest
:
for
field
in
rest
:
i
=
string
.
find
(
field
,
'='
)
i
=
field
.
find
(
'='
)
if
i
<
0
:
if
i
<
0
:
fkey
=
field
fkey
=
field
fvalue
=
""
fvalue
=
""
else
:
else
:
fkey
=
string
.
strip
(
field
[:
i
]
)
fkey
=
field
[:
i
]
.
strip
(
)
fvalue
=
string
.
strip
(
field
[
i
+
1
:]
)
fvalue
=
field
[
i
+
1
:]
.
strip
(
)
if
fields
.
has_key
(
fkey
):
if
fields
.
has_key
(
fkey
):
# Ignore it
# Ignore it
pass
pass
...
@@ -131,7 +130,7 @@ def parsefield(line, i, n):
...
@@ -131,7 +130,7 @@ def parsefield(line, i, n):
i
=
i
+
2
i
=
i
+
2
else
:
else
:
i
=
i
+
1
i
=
i
+
1
return
string
.
strip
(
line
[
start
:
i
]
),
i
return
line
[
start
:
i
]
.
strip
(
),
i
# Part 3: using the database.
# Part 3: using the database.
...
@@ -160,7 +159,7 @@ def lookup(caps, MIMEtype, key=None):
...
@@ -160,7 +159,7 @@ def lookup(caps, MIMEtype, key=None):
entries
=
[]
entries
=
[]
if
caps
.
has_key
(
MIMEtype
):
if
caps
.
has_key
(
MIMEtype
):
entries
=
entries
+
caps
[
MIMEtype
]
entries
=
entries
+
caps
[
MIMEtype
]
MIMEtypes
=
string
.
splitfields
(
MIMEtype
,
'/'
)
MIMEtypes
=
MIMEtype
.
split
(
'/'
)
MIMEtype
=
MIMEtypes
[
0
]
+
'/*'
MIMEtype
=
MIMEtypes
[
0
]
+
'/*'
if
caps
.
has_key
(
MIMEtype
):
if
caps
.
has_key
(
MIMEtype
):
entries
=
entries
+
caps
[
MIMEtype
]
entries
=
entries
+
caps
[
MIMEtype
]
...
@@ -201,10 +200,10 @@ def subst(field, MIMEtype, filename, plist=[]):
...
@@ -201,10 +200,10 @@ def subst(field, MIMEtype, filename, plist=[]):
return
res
return
res
def
findparam
(
name
,
plist
):
def
findparam
(
name
,
plist
):
name
=
string
.
lower
(
name
)
+
'='
name
=
name
.
lower
(
)
+
'='
n
=
len
(
name
)
n
=
len
(
name
)
for
p
in
plist
:
for
p
in
plist
:
if
string
.
lower
(
p
[:
n
]
)
==
name
:
if
p
[:
n
]
.
lower
(
)
==
name
:
return
p
[
n
:]
return
p
[
n
:]
return
''
return
''
...
...
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