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
a25d7ddb
Kaydet (Commit)
a25d7ddb
authored
Nis 10, 2000
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Some cleanup -- don't use splitfields/joinfields, standardize
indentation (tabs only), rationalize some code in urljoin...
üst
3bb1edb3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
urlparse.py
Lib/urlparse.py
+17
-19
No files found.
Lib/urlparse.py
Dosyayı görüntüle @
a25d7ddb
...
...
@@ -6,7 +6,7 @@ UC Irvine, June 1995.
# Standard/builtin Python modules
import
string
from
string
import
join
fields
,
splitfields
,
rfind
from
string
import
join
,
split
,
rfind
# A classification of schemes ('' means apply by default)
uses_relative
=
[
'ftp'
,
'http'
,
'gopher'
,
'nntp'
,
'wais'
,
'file'
,
...
...
@@ -37,9 +37,9 @@ MAX_CACHE_SIZE = 20
_parse_cache
=
{}
def
clear_cache
():
"""Clear the parse cache."""
global
_parse_cache
_parse_cache
=
{}
"""Clear the parse cache."""
global
_parse_cache
_parse_cache
=
{}
def
urlparse
(
url
,
scheme
=
''
,
allow_fragments
=
1
):
...
...
@@ -53,7 +53,7 @@ def urlparse(url, scheme = '', allow_fragments = 1):
if
cached
:
return
cached
if
len
(
_parse_cache
)
>=
MAX_CACHE_SIZE
:
# avoid runaway growth
clear_cache
()
clear_cache
()
find
=
string
.
find
netloc
=
path
=
params
=
query
=
fragment
=
''
i
=
find
(
url
,
':'
)
...
...
@@ -151,10 +151,8 @@ def urljoin(base, url, allow_fragments = 1):
if
not
path
:
return
urlunparse
((
scheme
,
netloc
,
bpath
,
params
,
query
or
bquery
,
fragment
))
i
=
rfind
(
bpath
,
'/'
)
if
i
>=
0
:
path
=
bpath
[:
i
]
+
'/'
+
path
segments
=
splitfields
(
path
,
'/'
)
segments
=
split
(
bpath
,
'/'
)[:
-
1
]
+
split
(
path
,
'/'
)
# XXX The stuff below is bogus in various ways...
if
segments
[
-
1
]
==
'.'
:
segments
[
-
1
]
=
''
while
'.'
in
segments
:
...
...
@@ -173,19 +171,19 @@ def urljoin(base, url, allow_fragments = 1):
segments
[
-
1
]
=
''
elif
len
(
segments
)
>=
2
and
segments
[
-
1
]
==
'..'
:
segments
[
-
2
:]
=
[
''
]
return
urlunparse
((
scheme
,
netloc
,
join
fields
(
segments
,
'/'
),
return
urlunparse
((
scheme
,
netloc
,
join
(
segments
,
'/'
),
params
,
query
,
fragment
))
def
urldefrag
(
url
):
"""Removes any existing fragment from URL.
Returns a tuple of the defragmented URL and the fragment. If
the URL contained no fragments, the second element is the
empty string.
"""
s
,
n
,
p
,
a
,
q
,
frag
=
urlparse
(
url
)
defrag
=
urlunparse
((
s
,
n
,
p
,
a
,
q
,
''
))
return
defrag
,
frag
"""Removes any existing fragment from URL.
Returns a tuple of the defragmented URL and the fragment. If
the URL contained no fragments, the second element is the
empty string.
"""
s
,
n
,
p
,
a
,
q
,
frag
=
urlparse
(
url
)
defrag
=
urlunparse
((
s
,
n
,
p
,
a
,
q
,
''
))
return
defrag
,
frag
test_input
=
"""
...
...
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