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
dfae912d
Kaydet (Commit)
dfae912d
authored
Ock 11, 2013
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15539: Fix backup file creation in pindent.py on Windows
üst
8b41c2e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
test_tools.py
Lib/test/test_tools.py
+1
-0
pindent.py
Tools/scripts/pindent.py
+22
-12
No files found.
Lib/test/test_tools.py
Dosyayı görüntüle @
dfae912d
...
@@ -57,6 +57,7 @@ class PindentTests(unittest.TestCase):
...
@@ -57,6 +57,7 @@ class PindentTests(unittest.TestCase):
return
'
\n
'
.
join
(
line
.
lstrip
()
for
line
in
data
.
splitlines
())
+
'
\n
'
return
'
\n
'
.
join
(
line
.
lstrip
()
for
line
in
data
.
splitlines
())
+
'
\n
'
def
test_selftest
(
self
):
def
test_selftest
(
self
):
self
.
maxDiff
=
None
with
temp_dir
()
as
directory
:
with
temp_dir
()
as
directory
:
data_path
=
os
.
path
.
join
(
directory
,
'_test.py'
)
data_path
=
os
.
path
.
join
(
directory
,
'_test.py'
)
with
open
(
self
.
script
)
as
f
:
with
open
(
self
.
script
)
as
f
:
...
...
Tools/scripts/pindent.py
Dosyayı görüntüle @
dfae912d
...
@@ -76,6 +76,8 @@
...
@@ -76,6 +76,8 @@
# - realign comments
# - realign comments
# - optionally do much more thorough reformatting, a la C indent
# - optionally do much more thorough reformatting, a la C indent
from
__future__
import
print_function
# Defaults
# Defaults
STEPSIZE
=
8
STEPSIZE
=
8
TABSIZE
=
8
TABSIZE
=
8
...
@@ -370,6 +372,23 @@ def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
...
@@ -370,6 +372,23 @@ def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
return
output
.
getvalue
()
return
output
.
getvalue
()
# end def reformat_string
# end def reformat_string
def
make_backup
(
filename
):
import
os
,
os
.
path
backup
=
filename
+
'~'
if
os
.
path
.
lexists
(
backup
):
try
:
os
.
remove
(
backup
)
except
os
.
error
:
print
(
"Can't remove backup
%
r"
%
(
backup
,),
file
=
sys
.
stderr
)
# end try
# end if
try
:
os
.
rename
(
filename
,
backup
)
except
os
.
error
:
print
(
"Can't rename
%
r to
%
r"
%
(
filename
,
backup
),
file
=
sys
.
stderr
)
# end try
# end def make_backup
def
complete_file
(
filename
,
stepsize
=
STEPSIZE
,
tabsize
=
TABSIZE
,
expandtabs
=
EXPANDTABS
):
def
complete_file
(
filename
,
stepsize
=
STEPSIZE
,
tabsize
=
TABSIZE
,
expandtabs
=
EXPANDTABS
):
with
open
(
filename
,
'r'
)
as
f
:
with
open
(
filename
,
'r'
)
as
f
:
source
=
f
.
read
()
source
=
f
.
read
()
...
@@ -377,10 +396,7 @@ def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
...
@@ -377,10 +396,7 @@ def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
result
=
complete_string
(
source
,
stepsize
,
tabsize
,
expandtabs
)
result
=
complete_string
(
source
,
stepsize
,
tabsize
,
expandtabs
)
if
source
==
result
:
return
0
if
source
==
result
:
return
0
# end if
# end if
import
os
make_backup
(
filename
)
try
:
os
.
rename
(
filename
,
filename
+
'~'
)
except
os
.
error
:
pass
# end try
with
open
(
filename
,
'w'
)
as
f
:
with
open
(
filename
,
'w'
)
as
f
:
f
.
write
(
result
)
f
.
write
(
result
)
# end with
# end with
...
@@ -394,10 +410,7 @@ def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = E
...
@@ -394,10 +410,7 @@ def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = E
result
=
delete_string
(
source
,
stepsize
,
tabsize
,
expandtabs
)
result
=
delete_string
(
source
,
stepsize
,
tabsize
,
expandtabs
)
if
source
==
result
:
return
0
if
source
==
result
:
return
0
# end if
# end if
import
os
make_backup
(
filename
)
try
:
os
.
rename
(
filename
,
filename
+
'~'
)
except
os
.
error
:
pass
# end try
with
open
(
filename
,
'w'
)
as
f
:
with
open
(
filename
,
'w'
)
as
f
:
f
.
write
(
result
)
f
.
write
(
result
)
# end with
# end with
...
@@ -411,10 +424,7 @@ def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
...
@@ -411,10 +424,7 @@ def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs =
result
=
reformat_string
(
source
,
stepsize
,
tabsize
,
expandtabs
)
result
=
reformat_string
(
source
,
stepsize
,
tabsize
,
expandtabs
)
if
source
==
result
:
return
0
if
source
==
result
:
return
0
# end if
# end if
import
os
make_backup
(
filename
)
try
:
os
.
rename
(
filename
,
filename
+
'~'
)
except
os
.
error
:
pass
# end try
with
open
(
filename
,
'w'
)
as
f
:
with
open
(
filename
,
'w'
)
as
f
:
f
.
write
(
result
)
f
.
write
(
result
)
# end with
# end with
...
...
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