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
49d7149e
Kaydet (Commit)
49d7149e
authored
Mar 08, 2011
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
transform izip_longest #11424
üst
3f84b078
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
13 deletions
+29
-13
fix_itertools.py
Lib/lib2to3/fixes/fix_itertools.py
+3
-2
fix_itertools_imports.py
Lib/lib2to3/fixes/fix_itertools_imports.py
+3
-2
test_fixers.py
Lib/lib2to3/tests/test_fixers.py
+23
-9
No files found.
Lib/lib2to3/fixes/fix_itertools.py
Dosyayı görüntüle @
49d7149e
...
...
@@ -13,7 +13,7 @@ from ..fixer_util import Name
class
FixItertools
(
fixer_base
.
BaseFix
):
BM_compatible
=
True
it_funcs
=
"('imap'|'ifilter'|'izip'|'ifilterfalse')"
it_funcs
=
"('imap'|'ifilter'|'izip'|'i
zip_longest'|'i
filterfalse')"
PATTERN
=
"""
power< it='itertools'
trailer<
...
...
@@ -28,7 +28,8 @@ class FixItertools(fixer_base.BaseFix):
def
transform
(
self
,
node
,
results
):
prefix
=
None
func
=
results
[
'func'
][
0
]
if
'it'
in
results
and
func
.
value
!=
'ifilterfalse'
:
if
(
'it'
in
results
and
func
.
value
not
in
(
'ifilterfalse'
,
'izip_longest'
)):
dot
,
it
=
(
results
[
'dot'
],
results
[
'it'
])
# Remove the 'itertools'
prefix
=
it
.
prefix
...
...
Lib/lib2to3/fixes/fix_itertools_imports.py
Dosyayı görüntüle @
49d7149e
...
...
@@ -31,9 +31,10 @@ class FixItertoolsImports(fixer_base.BaseFix):
if
member_name
in
(
'imap'
,
'izip'
,
'ifilter'
):
child
.
value
=
None
child
.
remove
()
elif
member_name
==
'ifilterfalse'
:
elif
member_name
in
(
'ifilterfalse'
,
'izip_longest'
)
:
node
.
changed
()
name_node
.
value
=
'filterfalse'
name_node
.
value
=
(
'filterfalse'
if
member_name
[
1
]
==
'f'
else
'zip_longest'
)
# Make sure the import statement is still sane
children
=
imports
.
children
[:]
or
[
imports
]
...
...
Lib/lib2to3/tests/test_fixers.py
Dosyayı görüntüle @
49d7149e
...
...
@@ -3623,16 +3623,24 @@ class Test_itertools(FixerTestCase):
a
=
"""
%
s(f, a)"""
self
.
checkall
(
b
,
a
)
def
test_
2
(
self
):
def
test_
qualified
(
self
):
b
=
"""itertools.ifilterfalse(a, b)"""
a
=
"""itertools.filterfalse(a, b)"""
self
.
check
(
b
,
a
)
def
test_4
(
self
):
b
=
"""itertools.izip_longest(a, b)"""
a
=
"""itertools.zip_longest(a, b)"""
self
.
check
(
b
,
a
)
def
test_2
(
self
):
b
=
"""ifilterfalse(a, b)"""
a
=
"""filterfalse(a, b)"""
self
.
check
(
b
,
a
)
b
=
"""izip_longest(a, b)"""
a
=
"""zip_longest(a, b)"""
self
.
check
(
b
,
a
)
def
test_space_1
(
self
):
b
=
"""
%
s(f, a)"""
a
=
"""
%
s(f, a)"""
...
...
@@ -3643,9 +3651,14 @@ class Test_itertools(FixerTestCase):
a
=
""" itertools.filterfalse(a, b)"""
self
.
check
(
b
,
a
)
b
=
""" itertools.izip_longest(a, b)"""
a
=
""" itertools.zip_longest(a, b)"""
self
.
check
(
b
,
a
)
def
test_run_order
(
self
):
self
.
assert_runs_after
(
'map'
,
'zip'
,
'filter'
)
class
Test_itertools_imports
(
FixerTestCase
):
fixer
=
'itertools_imports'
...
...
@@ -3696,17 +3709,18 @@ class Test_itertools_imports(FixerTestCase):
s
=
"from itertools import bar as bang"
self
.
unchanged
(
s
)
def
test_ifilter
(
self
):
b
=
"from itertools import ifilterfalse"
a
=
"from itertools import filterfalse"
def
test_ifilter_and_zip_longest
(
self
):
for
name
in
"filterfalse"
,
"zip_longest"
:
b
=
"from itertools import i
%
s"
%
(
name
,)
a
=
"from itertools import
%
s"
%
(
name
,)
self
.
check
(
b
,
a
)
b
=
"from itertools import imap, ifilterfalse, foo"
a
=
"from itertools import filterfalse, foo"
b
=
"from itertools import imap, i
%
s, foo"
%
(
name
,)
a
=
"from itertools import
%
s, foo"
%
(
name
,)
self
.
check
(
b
,
a
)
b
=
"from itertools import bar, ifilterfalse, foo"
a
=
"from itertools import bar, filterfalse, foo"
b
=
"from itertools import bar, i
%
s, foo"
%
(
name
,)
a
=
"from itertools import bar,
%
s, foo"
%
(
name
,)
self
.
check
(
b
,
a
)
def
test_import_star
(
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