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
c9423109
Kaydet (Commit)
c9423109
authored
Şub 22, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Factor-out common code for helper classes.
üst
16fe75e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
20 deletions
+4
-20
__init__.py
Lib/collections/__init__.py
+1
-1
string.py
Lib/string.py
+3
-19
No files found.
Lib/collections/__init__.py
Dosyayı görüntüle @
c9423109
...
...
@@ -633,7 +633,7 @@ class Counter(dict):
########################################################################
### ChainMap (helper for configparser)
### ChainMap (helper for configparser
and string.Template
)
########################################################################
class
_ChainMap
(
MutableMapping
):
...
...
Lib/string.py
Dosyayı görüntüle @
c9423109
...
...
@@ -46,23 +46,7 @@ def capwords(s, sep=None):
####################################################################
import
re
as
_re
class
_multimap
:
"""Helper class for combining multiple mappings.
Used by .{safe_,}substitute() to combine the mapping and keyword
arguments.
"""
def
__init__
(
self
,
primary
,
secondary
):
self
.
_primary
=
primary
self
.
_secondary
=
secondary
def
__getitem__
(
self
,
key
):
try
:
return
self
.
_primary
[
key
]
except
KeyError
:
return
self
.
_secondary
[
key
]
from
collections
import
_ChainMap
class
_TemplateMetaclass
(
type
):
pattern
=
r"""
...
...
@@ -116,7 +100,7 @@ class Template(metaclass=_TemplateMetaclass):
if
not
args
:
mapping
=
kws
elif
kws
:
mapping
=
_
multim
ap
(
kws
,
args
[
0
])
mapping
=
_
ChainM
ap
(
kws
,
args
[
0
])
else
:
mapping
=
args
[
0
]
# Helper function for .sub()
...
...
@@ -142,7 +126,7 @@ class Template(metaclass=_TemplateMetaclass):
if
not
args
:
mapping
=
kws
elif
kws
:
mapping
=
_
multim
ap
(
kws
,
args
[
0
])
mapping
=
_
ChainM
ap
(
kws
,
args
[
0
])
else
:
mapping
=
args
[
0
]
# Helper function for .sub()
...
...
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