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
7cd94b8a
Kaydet (Commit)
7cd94b8a
authored
Eki 19, 2010
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue10140 - Tools/scripts/pathfix.py: add option to preserve timestamps
üst
e474309b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
pathfix.py
Tools/scripts/pathfix.py
+18
-3
No files found.
Tools/scripts/pathfix.py
Dosyayı görüntüle @
7cd94b8a
...
@@ -30,20 +30,24 @@ dbg = err
...
@@ -30,20 +30,24 @@ dbg = err
rep
=
sys
.
stdout
.
write
rep
=
sys
.
stdout
.
write
new_interpreter
=
None
new_interpreter
=
None
preserve_timestamps
=
False
def
main
():
def
main
():
global
new_interpreter
global
new_interpreter
usage
=
(
'usage:
%
s -i /interpreter file-or-directory ...
\n
'
%
global
preserve_timestamps
usage
=
(
'usage:
%
s -i /interpreter -p file-or-directory ...
\n
'
%
sys
.
argv
[
0
])
sys
.
argv
[
0
])
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'i:'
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'i:
p
'
)
except
getopt
.
error
as
msg
:
except
getopt
.
error
as
msg
:
err
(
msg
+
'
\n
'
)
err
(
str
(
msg
)
+
'
\n
'
)
err
(
usage
)
err
(
usage
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
for
o
,
a
in
opts
:
if
o
==
'-i'
:
if
o
==
'-i'
:
new_interpreter
=
a
.
encode
()
new_interpreter
=
a
.
encode
()
if
o
==
'-p'
:
preserve_timestamps
=
True
if
not
new_interpreter
or
not
new_interpreter
.
startswith
(
b
'/'
)
or
\
if
not
new_interpreter
or
not
new_interpreter
.
startswith
(
b
'/'
)
or
\
not
args
:
not
args
:
err
(
'-i option or file-or-directory missing
\n
'
)
err
(
'-i option or file-or-directory missing
\n
'
)
...
@@ -119,9 +123,13 @@ def fix(filename):
...
@@ -119,9 +123,13 @@ def fix(filename):
# Finishing touch -- move files
# Finishing touch -- move files
mtime
=
None
atime
=
None
# First copy the file's mode to the temp file
# First copy the file's mode to the temp file
try
:
try
:
statbuf
=
os
.
stat
(
filename
)
statbuf
=
os
.
stat
(
filename
)
mtime
=
statbuf
.
st_mtime
atime
=
statbuf
.
st_atime
os
.
chmod
(
tempname
,
statbuf
[
ST_MODE
]
&
0
o7777
)
os
.
chmod
(
tempname
,
statbuf
[
ST_MODE
]
&
0
o7777
)
except
os
.
error
as
msg
:
except
os
.
error
as
msg
:
err
(
'
%
s: warning: chmod failed (
%
r)
\n
'
%
(
tempname
,
msg
))
err
(
'
%
s: warning: chmod failed (
%
r)
\n
'
%
(
tempname
,
msg
))
...
@@ -136,6 +144,13 @@ def fix(filename):
...
@@ -136,6 +144,13 @@ def fix(filename):
except
os
.
error
as
msg
:
except
os
.
error
as
msg
:
err
(
'
%
s: rename failed (
%
r)
\n
'
%
(
filename
,
msg
))
err
(
'
%
s: rename failed (
%
r)
\n
'
%
(
filename
,
msg
))
return
1
return
1
if
preserve_timestamps
:
if
atime
and
mtime
:
try
:
os
.
utime
(
filename
,
(
atime
,
mtime
))
except
os
.
error
as
msg
:
err
(
'
%
s: reset of timestamp failed (
%
r)
\n
'
%
(
filename
,
msg
))
return
1
# Return succes
# Return succes
return
0
return
0
...
...
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