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
3534a893
Kaydet (Commit)
3534a893
authored
Tem 30, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
New, improved parseaddr() by Sjoerd.
üst
7698d12a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
30 deletions
+83
-30
rfc822.py
Lib/rfc822.py
+83
-30
No files found.
Lib/rfc822.py
Dosyayı görüntüle @
3534a893
...
@@ -297,35 +297,88 @@ def unquote(str):
...
@@ -297,35 +297,88 @@ def unquote(str):
# Parse an address into (name, address) tuple
# Parse an address into (name, address) tuple
def
parseaddr
(
address
):
def
parseaddr
(
address
):
# This is probably not perfect
import
string
address
=
string
.
strip
(
address
)
str
=
''
# Case 1: part of the address is in <xx@xx> form.
email
=
''
pos
=
regex
.
search
(
'<.*>'
,
address
)
comment
=
''
if
pos
>=
0
:
backslash
=
0
name
=
address
[:
pos
]
dquote
=
0
address
=
address
[
pos
:]
space
=
0
length
=
regex
.
match
(
'<.*>'
,
address
)
paren
=
0
name
=
name
+
address
[
length
:]
bracket
=
0
address
=
address
[:
length
]
seen_bracket
=
0
else
:
for
c
in
address
:
# Case 2: part of the address is in (comment) form
if
backslash
:
pos
=
regex
.
search
(
'(.*)'
,
address
)
str
=
str
+
c
if
pos
>=
0
:
backslash
=
0
name
=
address
[
pos
:]
continue
address
=
address
[:
pos
]
if
c
==
'
\\
'
:
length
=
regex
.
match
(
'(.*)'
,
name
)
backslash
=
1
address
=
address
+
name
[
length
:]
continue
name
=
name
[:
length
]
if
dquote
:
if
c
==
'"'
:
dquote
=
0
else
:
str
=
str
+
c
continue
if
c
==
'"'
:
dquote
=
1
continue
if
c
in
string
.
whitespace
:
space
=
1
continue
if
space
:
str
=
str
+
' '
space
=
0
if
paren
:
if
c
==
'('
:
paren
=
paren
+
1
str
=
str
+
c
continue
if
c
==
')'
:
paren
=
paren
-
1
if
paren
==
0
:
comment
=
comment
+
str
str
=
''
continue
if
c
==
'('
:
paren
=
paren
+
1
if
bracket
:
email
=
email
+
str
str
=
''
elif
not
seen_bracket
:
email
=
email
+
str
str
=
''
continue
if
bracket
:
if
c
==
'>'
:
bracket
=
0
email
=
email
+
str
str
=
''
continue
if
c
==
'<'
:
bracket
=
1
seen_bracket
=
1
comment
=
comment
+
str
str
=
''
email
=
''
continue
if
c
==
'#'
and
not
bracket
and
not
paren
:
# rest is comment
break
str
=
str
+
c
if
str
:
if
seen_bracket
:
if
bracket
:
email
=
str
else
:
comment
=
comment
+
str
else
:
else
:
# Case 3: neither. Only an address
if
paren
:
name
=
''
comment
=
comment
+
str
name
=
string
.
strip
(
name
)
else
:
address
=
string
.
strip
(
address
)
email
=
email
+
str
if
address
and
address
[
0
]
==
'<'
and
address
[
-
1
]
==
'>'
:
return
string
.
strip
(
comment
),
string
.
strip
(
email
)
address
=
address
[
1
:
-
1
]
if
name
and
name
[
0
]
==
'('
and
name
[
-
1
]
==
')'
:
name
=
name
[
1
:
-
1
]
return
name
,
address
# Parse a date field
# Parse a date field
...
@@ -376,8 +429,8 @@ def parsedate(data):
...
@@ -376,8 +429,8 @@ def parsedate(data):
# message in RFC-822 format.
# message in RFC-822 format.
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
import
sys
import
sys
,
os
file
=
'/ufs/guido/Mail/drafts/,1'
file
=
os
.
path
.
join
(
os
.
environ
[
'HOME'
],
'Mail/drafts/,1'
)
if
sys
.
argv
[
1
:]:
file
=
sys
.
argv
[
1
]
if
sys
.
argv
[
1
:]:
file
=
sys
.
argv
[
1
]
f
=
open
(
file
,
'r'
)
f
=
open
(
file
,
'r'
)
m
=
Message
(
f
)
m
=
Message
(
f
)
...
...
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