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
0f6a656e
Kaydet (Commit)
0f6a656e
authored
Ock 11, 2008
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Speed-up and simplify code urlparse's result objects.
üst
0f973934
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
52 deletions
+6
-52
urlparse.py
Lib/urlparse.py
+6
-52
No files found.
Lib/urlparse.py
Dosyayı görüntüle @
0f6a656e
...
...
@@ -37,46 +37,11 @@ _parse_cache = {}
def
clear_cache
():
"""Clear the parse cache."""
global
_parse_cache
_parse_cache
=
{}
_parse_cache
.
clear
()
class
BaseResult
(
tuple
):
"""Base class for the parsed result objects.
This provides the attributes shared by the two derived result
objects as read-only properties. The derived classes are
responsible for checking the right number of arguments were
supplied to the constructor.
"""
__slots__
=
()
# Attributes that access the basic components of the URL:
@property
def
scheme
(
self
):
return
self
[
0
]
@property
def
netloc
(
self
):
return
self
[
1
]
@property
def
path
(
self
):
return
self
[
2
]
@property
def
query
(
self
):
return
self
[
-
2
]
@property
def
fragment
(
self
):
return
self
[
-
1
]
# Additional attributes that provide access to parsed-out portions
# of the netloc:
class
ResultMixin
(
object
):
"""Shared methods for the parsed result objects."""
@property
def
username
(
self
):
...
...
@@ -116,31 +81,20 @@ class BaseResult(tuple):
return
int
(
port
,
10
)
return
None
from
collections
import
namedtuple
class
SplitResult
(
BaseResult
):
class
SplitResult
(
namedtuple
(
'SplitResult'
,
'scheme netloc path query fragment'
),
ResultMixin
):
__slots__
=
()
def
__new__
(
cls
,
scheme
,
netloc
,
path
,
query
,
fragment
):
return
BaseResult
.
__new__
(
cls
,
(
scheme
,
netloc
,
path
,
query
,
fragment
))
def
geturl
(
self
):
return
urlunsplit
(
self
)
class
ParseResult
(
BaseResult
):
class
ParseResult
(
namedtuple
(
'ParseResult'
,
'scheme netloc path params query fragment'
),
ResultMixin
):
__slots__
=
()
def
__new__
(
cls
,
scheme
,
netloc
,
path
,
params
,
query
,
fragment
):
return
BaseResult
.
__new__
(
cls
,
(
scheme
,
netloc
,
path
,
params
,
query
,
fragment
))
@property
def
params
(
self
):
return
self
[
3
]
def
geturl
(
self
):
return
urlunparse
(
self
)
...
...
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