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
47e120e7
Kaydet (Commit)
47e120e7
authored
Nis 11, 2011
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Cleanup and modernize code prior to working on Issue 11747.
üst
bed9a5b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
26 deletions
+27
-26
difflib.py
Lib/difflib.py
+27
-26
No files found.
Lib/difflib.py
Dosyayı görüntüle @
47e120e7
...
...
@@ -1188,22 +1188,23 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
started
=
False
for
group
in
SequenceMatcher
(
None
,
a
,
b
)
.
get_grouped_opcodes
(
n
):
if
not
started
:
fromdate
=
'
\t
%
s'
%
fromfiledate
if
fromfiledate
else
''
todate
=
'
\t
%
s'
%
tofiledate
if
tofiledate
else
''
yield
'---
%
s
%
s
%
s'
%
(
fromfile
,
fromdate
,
lineterm
)
yield
'+++
%
s
%
s
%
s'
%
(
tofile
,
todate
,
lineterm
)
started
=
True
i1
,
i2
,
j1
,
j2
=
group
[
0
][
1
],
group
[
-
1
][
2
],
group
[
0
][
3
],
group
[
-
1
][
4
]
yield
"@@ -
%
d,
%
d +
%
d,
%
d @@
%
s"
%
(
i1
+
1
,
i2
-
i1
,
j1
+
1
,
j2
-
j1
,
lineterm
)
fromdate
=
'
\t
{}'
.
format
(
fromfiledate
)
if
fromfiledate
else
''
todate
=
'
\t
{}'
.
format
(
tofiledate
)
if
tofiledate
else
''
yield
'--- {}{}{}'
.
format
(
fromfile
,
fromdate
,
lineterm
)
yield
'+++ {}{}{}'
.
format
(
tofile
,
todate
,
lineterm
)
first
,
last
=
group
[
0
],
group
[
-
1
]
i1
,
i2
,
j1
,
j2
=
first
[
1
],
last
[
2
],
first
[
3
],
last
[
4
]
yield
'@@ -{},{} +{},{} @@{}'
.
format
(
i1
+
1
,
i2
-
i1
,
j1
+
1
,
j2
-
j1
,
lineterm
)
for
tag
,
i1
,
i2
,
j1
,
j2
in
group
:
if
tag
==
'equal'
:
for
line
in
a
[
i1
:
i2
]:
yield
' '
+
line
continue
if
tag
==
'replace'
or
tag
==
'delete'
:
if
tag
in
{
'replace'
,
'delete'
}
:
for
line
in
a
[
i1
:
i2
]:
yield
'-'
+
line
if
tag
==
'replace'
or
tag
==
'insert'
:
if
tag
in
{
'replace'
,
'insert'
}
:
for
line
in
b
[
j1
:
j2
]:
yield
'+'
+
line
...
...
@@ -1252,38 +1253,38 @@ def context_diff(a, b, fromfile='', tofile='',
four
"""
prefix
=
dict
(
insert
=
'+ '
,
delete
=
'- '
,
replace
=
'! '
,
equal
=
' '
)
started
=
False
prefixmap
=
{
'insert'
:
'+ '
,
'delete'
:
'- '
,
'replace'
:
'! '
,
'equal'
:
' '
}
for
group
in
SequenceMatcher
(
None
,
a
,
b
)
.
get_grouped_opcodes
(
n
):
if
not
started
:
fromdate
=
'
\t
%
s'
%
fromfiledate
if
fromfiledate
else
''
todate
=
'
\t
%
s'
%
tofiledate
if
tofiledate
else
''
yield
'***
%
s
%
s
%
s'
%
(
fromfile
,
fromdate
,
lineterm
)
yield
'---
%
s
%
s
%
s'
%
(
tofile
,
todate
,
lineterm
)
started
=
True
fromdate
=
'
\t
{}'
.
format
(
fromfiledate
)
if
fromfiledate
else
''
todate
=
'
\t
{}'
.
format
(
tofiledate
)
if
tofiledate
else
''
yield
'*** {}{}{}'
.
format
(
fromfile
,
fromdate
,
lineterm
)
yield
'--- {}{}{}'
.
format
(
tofile
,
todate
,
lineterm
)
yield
'***************
%
s'
%
(
lineterm
,)
if
group
[
-
1
][
2
]
-
group
[
0
][
1
]
>=
2
:
yield
'***
%
d,
%
d ****
%
s'
%
(
group
[
0
][
1
]
+
1
,
group
[
-
1
][
2
],
lineterm
)
first
,
last
=
group
[
0
],
group
[
-
1
]
yield
'***************{}'
.
format
(
lineterm
)
if
last
[
2
]
-
first
[
1
]
>
1
:
yield
'*** {},{} ****{}'
.
format
(
first
[
1
]
+
1
,
last
[
2
],
lineterm
)
else
:
yield
'***
%
d ****
%
s'
%
(
group
[
-
1
][
2
],
lineterm
)
visiblechanges
=
[
e
for
e
in
group
if
e
[
0
]
in
(
'replace'
,
'delete'
)]
if
visiblechanges
:
yield
'*** {} ****{}'
.
format
(
last
[
2
],
lineterm
)
if
any
(
tag
in
{
'replace'
,
'delete'
}
for
tag
,
_
,
_
,
_
,
_
in
group
):
for
tag
,
i1
,
i2
,
_
,
_
in
group
:
if
tag
!=
'insert'
:
for
line
in
a
[
i1
:
i2
]:
yield
prefix
map
[
tag
]
+
line
yield
prefix
[
tag
]
+
line
if
group
[
-
1
][
4
]
-
group
[
0
][
3
]
>=
2
:
yield
'---
%
d,
%
d ----
%
s'
%
(
group
[
0
][
3
]
+
1
,
group
[
-
1
]
[
4
],
lineterm
)
if
last
[
4
]
-
first
[
3
]
>
1
:
yield
'---
{},{} ----{}'
.
format
(
first
[
3
]
+
1
,
last
[
4
],
lineterm
)
else
:
yield
'---
%
d ----
%
s'
%
(
group
[
-
1
][
4
],
lineterm
)
visiblechanges
=
[
e
for
e
in
group
if
e
[
0
]
in
(
'replace'
,
'insert'
)]
if
visiblechanges
:
yield
'--- {} ----{}'
.
format
(
last
[
4
],
lineterm
)
if
any
(
tag
in
{
'replace'
,
'insert'
}
for
tag
,
_
,
_
,
_
,
_
in
group
):
for
tag
,
_
,
_
,
j1
,
j2
in
group
:
if
tag
!=
'delete'
:
for
line
in
b
[
j1
:
j2
]:
yield
prefix
map
[
tag
]
+
line
yield
prefix
[
tag
]
+
line
def
ndiff
(
a
,
b
,
linejunk
=
None
,
charjunk
=
IS_CHARACTER_JUNK
):
r"""
...
...
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