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
ed5b3d8b
Kaydet (Commit)
ed5b3d8b
authored
Mar 24, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
give in to tab police
üst
3db0e371
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
440 additions
and
435 deletions
+440
-435
cvsfiles.py
Tools/scripts/cvsfiles.py
+29
-29
fixnotice.py
Tools/scripts/fixnotice.py
+4
-4
linktree.py
Tools/scripts/linktree.py
+20
-17
logmerge.py
Tools/scripts/logmerge.py
+63
-63
mailerdaemon.py
Tools/scripts/mailerdaemon.py
+226
-224
treesync.py
Tools/scripts/treesync.py
+98
-98
No files found.
Tools/scripts/cvsfiles.py
Dosyayı görüntüle @
ed5b3d8b
...
...
@@ -20,53 +20,53 @@ cutofftime = 0
def
main
():
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"n:"
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"n:"
)
except
getopt
.
error
,
msg
:
print
msg
print
__doc__
,
return
1
print
msg
print
__doc__
,
return
1
global
cutofftime
newerfile
=
None
for
o
,
a
in
opts
:
if
o
==
'-n'
:
cutofftime
=
getmtime
(
a
)
if
o
==
'-n'
:
cutofftime
=
getmtime
(
a
)
if
args
:
for
arg
in
args
:
process
(
arg
)
for
arg
in
args
:
process
(
arg
)
else
:
process
(
"."
)
process
(
"."
)
def
process
(
dir
):
cvsdir
=
0
subdirs
=
[]
names
=
os
.
listdir
(
dir
)
for
name
in
names
:
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
name
==
"CVS"
:
cvsdir
=
fullname
else
:
if
os
.
path
.
isdir
(
fullname
):
if
not
os
.
path
.
islink
(
fullname
):
subdirs
.
append
(
fullname
)
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
name
==
"CVS"
:
cvsdir
=
fullname
else
:
if
os
.
path
.
isdir
(
fullname
):
if
not
os
.
path
.
islink
(
fullname
):
subdirs
.
append
(
fullname
)
if
cvsdir
:
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
)
.
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
cutofftime
and
getmtime
(
fullname
)
<=
cutofftime
:
pass
else
:
print
fullname
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
)
.
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
fullname
=
os
.
path
.
join
(
dir
,
name
)
if
cutofftime
and
getmtime
(
fullname
)
<=
cutofftime
:
pass
else
:
print
fullname
for
sub
in
subdirs
:
process
(
sub
)
process
(
sub
)
def
getmtime
(
filename
):
try
:
st
=
os
.
stat
(
filename
)
st
=
os
.
stat
(
filename
)
except
os
.
error
:
return
0
return
0
return
st
[
stat
.
ST_MTIME
]
sys
.
exit
(
main
())
Tools/scripts/fixnotice.py
Dosyayı görüntüle @
ed5b3d8b
...
...
@@ -50,9 +50,9 @@ import os, sys, string
def
main
():
args
=
sys
.
argv
[
1
:]
if
not
args
:
print
"No arguments."
print
"No arguments."
for
arg
in
args
:
process
(
arg
)
process
(
arg
)
def
process
(
arg
):
f
=
open
(
arg
)
...
...
@@ -60,8 +60,8 @@ def process(arg):
f
.
close
()
i
=
string
.
find
(
data
,
OLD_NOTICE
)
if
i
<
0
:
##
print "No old notice in", arg
return
##
print "No old notice in", arg
return
data
=
data
[:
i
]
+
NEW_NOTICE
+
data
[
i
+
len
(
OLD_NOTICE
):]
new
=
arg
+
".new"
backup
=
arg
+
".bak"
...
...
Tools/scripts/linktree.py
Dosyayı görüntüle @
ed5b3d8b
...
...
@@ -55,22 +55,25 @@ def linknames(old, new, link):
print
old
+
': warning: cannot listdir:'
,
msg
return
for
name
in
names
:
if
name
not
in
(
os
.
curdir
,
os
.
pardir
):
oldname
=
os
.
path
.
join
(
old
,
name
)
linkname
=
os
.
path
.
join
(
link
,
name
)
newname
=
os
.
path
.
join
(
new
,
name
)
if
debug
>
1
:
print
oldname
,
newname
,
linkname
if
os
.
path
.
isdir
(
oldname
)
and
not
os
.
path
.
islink
(
oldname
):
try
:
os
.
mkdir
(
newname
,
0777
)
ok
=
1
except
:
print
newname
+
': warning: cannot mkdir:'
,
msg
ok
=
0
if
ok
:
linkname
=
os
.
path
.
join
(
os
.
pardir
,
linkname
)
linknames
(
oldname
,
newname
,
linkname
)
else
:
os
.
symlink
(
linkname
,
newname
)
if
name
not
in
(
os
.
curdir
,
os
.
pardir
):
oldname
=
os
.
path
.
join
(
old
,
name
)
linkname
=
os
.
path
.
join
(
link
,
name
)
newname
=
os
.
path
.
join
(
new
,
name
)
if
debug
>
1
:
print
oldname
,
newname
,
linkname
if
os
.
path
.
isdir
(
oldname
)
and
\
not
os
.
path
.
islink
(
oldname
):
try
:
os
.
mkdir
(
newname
,
0777
)
ok
=
1
except
:
print
newname
+
\
': warning: cannot mkdir:'
,
msg
ok
=
0
if
ok
:
linkname
=
os
.
path
.
join
(
os
.
pardir
,
linkname
)
linknames
(
oldname
,
newname
,
linkname
)
else
:
os
.
symlink
(
linkname
,
newname
)
sys
.
exit
(
main
())
Tools/scripts/logmerge.py
Dosyayı görüntüle @
ed5b3d8b
...
...
@@ -26,25 +26,25 @@ from their output.
import
os
,
sys
,
getopt
,
string
,
re
sep1
=
'='
*
77
+
'
\n
'
# file separator
sep2
=
'-'
*
28
+
'
\n
'
# revision separator
sep1
=
'='
*
77
+
'
\n
'
# file separator
sep2
=
'-'
*
28
+
'
\n
'
# revision separator
def
main
():
"""Main program"""
truncate_last
=
0
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"-t"
)
for
o
,
a
in
opts
:
if
o
==
'-t'
:
truncate_last
=
1
if
o
==
'-t'
:
truncate_last
=
1
database
=
[]
while
1
:
chunk
=
read_chunk
(
sys
.
stdin
)
if
not
chunk
:
break
records
=
digest_chunk
(
chunk
)
if
truncate_last
:
del
records
[
-
1
]
database
[
len
(
database
):]
=
records
chunk
=
read_chunk
(
sys
.
stdin
)
if
not
chunk
:
break
records
=
digest_chunk
(
chunk
)
if
truncate_last
:
del
records
[
-
1
]
database
[
len
(
database
):]
=
records
database
.
sort
()
database
.
reverse
()
format_output
(
database
)
...
...
@@ -58,19 +58,19 @@ def read_chunk(fp):
chunk
=
[]
lines
=
[]
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
if
line
==
sep1
:
if
lines
:
chunk
.
append
(
lines
)
break
if
line
==
sep2
:
if
lines
:
chunk
.
append
(
lines
)
lines
=
[]
else
:
lines
.
append
(
line
)
line
=
fp
.
readline
()
if
not
line
:
break
if
line
==
sep1
:
if
lines
:
chunk
.
append
(
lines
)
break
if
line
==
sep2
:
if
lines
:
chunk
.
append
(
lines
)
lines
=
[]
else
:
lines
.
append
(
line
)
return
chunk
def
digest_chunk
(
chunk
):
...
...
@@ -79,53 +79,53 @@ def digest_chunk(chunk):
key
=
'Working file:'
keylen
=
len
(
key
)
for
line
in
lines
:
if
line
[:
keylen
]
==
key
:
working_file
=
string
.
strip
(
line
[
keylen
:])
break
if
line
[:
keylen
]
==
key
:
working_file
=
string
.
strip
(
line
[
keylen
:])
break
else
:
working_file
=
None
working_file
=
None
records
=
[]
for
lines
in
chunk
[
1
:]:
revline
=
lines
[
0
]
dateline
=
lines
[
1
]
text
=
lines
[
2
:]
words
=
string
.
split
(
dateline
)
author
=
None
if
len
(
words
)
>=
3
and
words
[
0
]
==
'date:'
:
dateword
=
words
[
1
]
timeword
=
words
[
2
]
if
timeword
[
-
1
:]
==
';'
:
timeword
=
timeword
[:
-
1
]
date
=
dateword
+
' '
+
timeword
if
len
(
words
)
>=
5
and
words
[
3
]
==
'author:'
:
author
=
words
[
4
]
if
author
[
-
1
:]
==
';'
:
author
=
author
[:
-
1
]
else
:
date
=
None
text
.
insert
(
0
,
revline
)
words
=
string
.
split
(
revline
)
if
len
(
words
)
>=
2
and
words
[
0
]
==
'revision'
:
rev
=
words
[
1
]
else
:
rev
=
None
text
.
insert
(
0
,
revline
)
records
.
append
((
date
,
working_file
,
rev
,
author
,
text
))
revline
=
lines
[
0
]
dateline
=
lines
[
1
]
text
=
lines
[
2
:]
words
=
string
.
split
(
dateline
)
author
=
None
if
len
(
words
)
>=
3
and
words
[
0
]
==
'date:'
:
dateword
=
words
[
1
]
timeword
=
words
[
2
]
if
timeword
[
-
1
:]
==
';'
:
timeword
=
timeword
[:
-
1
]
date
=
dateword
+
' '
+
timeword
if
len
(
words
)
>=
5
and
words
[
3
]
==
'author:'
:
author
=
words
[
4
]
if
author
[
-
1
:]
==
';'
:
author
=
author
[:
-
1
]
else
:
date
=
None
text
.
insert
(
0
,
revline
)
words
=
string
.
split
(
revline
)
if
len
(
words
)
>=
2
and
words
[
0
]
==
'revision'
:
rev
=
words
[
1
]
else
:
rev
=
None
text
.
insert
(
0
,
revline
)
records
.
append
((
date
,
working_file
,
rev
,
author
,
text
))
return
records
def
format_output
(
database
):
prevtext
=
None
prev
=
[]
database
.
append
((
None
,
None
,
None
,
None
,
None
))
# Sentinel
for
(
date
,
working_file
,
rev
,
author
,
text
)
in
database
:
if
text
!=
prevtext
:
if
prev
:
print
sep2
,
for
(
p_date
,
p_working_file
,
p_rev
,
p_author
)
in
prev
:
print
p_date
,
p_author
,
p_working_file
sys
.
stdout
.
writelines
(
prevtext
)
prev
=
[]
prev
.
append
((
date
,
working_file
,
rev
,
author
))
prevtext
=
text
if
text
!=
prevtext
:
if
prev
:
print
sep2
,
for
(
p_date
,
p_working_file
,
p_rev
,
p_author
)
in
prev
:
print
p_date
,
p_author
,
p_working_file
sys
.
stdout
.
writelines
(
prevtext
)
prev
=
[]
prev
.
append
((
date
,
working_file
,
rev
,
author
))
prevtext
=
text
main
()
Tools/scripts/mailerdaemon.py
Dosyayı görüntüle @
ed5b3d8b
...
...
@@ -11,264 +11,266 @@ Unparseable = 'mailerdaemon.Unparseable'
class
ErrorMessage
(
rfc822
.
Message
):
def
__init__
(
self
,
fp
):
rfc822
.
Message
.
__init__
(
self
,
fp
)
rfc822
.
Message
.
__init__
(
self
,
fp
)
def
is_warning
(
self
):
sub
=
self
.
getheader
(
'Subject'
)
if
not
sub
:
return
0
sub
=
string
.
lower
(
sub
)
if
sub
[:
12
]
==
'waiting mail'
:
return
1
if
string
.
find
(
sub
,
'warning'
)
>=
0
:
return
1
self
.
sub
=
sub
return
0
sub
=
self
.
getheader
(
'Subject'
)
if
not
sub
:
return
0
sub
=
string
.
lower
(
sub
)
if
sub
[:
12
]
==
'waiting mail'
:
return
1
if
string
.
find
(
sub
,
'warning'
)
>=
0
:
return
1
self
.
sub
=
sub
return
0
def
get_errors
(
self
):
for
p
in
EMPARSERS
:
self
.
rewindbody
()
try
:
return
p
(
self
.
fp
,
self
.
sub
)
except
Unparseable
:
pass
raise
Unparseable
for
p
in
EMPARSERS
:
self
.
rewindbody
()
try
:
return
p
(
self
.
fp
,
self
.
sub
)
except
Unparseable
:
pass
raise
Unparseable
sendmail_pattern
=
regex
.
compile
(
'[0-9][0-9][0-9] '
)
def
emparse_sendmail
(
fp
,
sub
):
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
line
=
string
.
split
(
line
)
if
len
(
line
)
>
3
and
\
((
line
[
0
]
==
'-----'
and
line
[
1
]
==
'Transcript'
)
or
(
line
[
0
]
==
'---'
and
line
[
1
]
==
'The'
and
line
[
2
]
==
'transcript'
)
or
(
line
[
0
]
==
'While'
and
line
[
1
]
==
'talking'
and
line
[
2
]
==
'to'
)):
# Yes, found it!
break
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
line
=
string
.
split
(
line
)
if
len
(
line
)
>
3
and
\
((
line
[
0
]
==
'-----'
and
line
[
1
]
==
'Transcript'
)
or
(
line
[
0
]
==
'---'
and
line
[
1
]
==
'The'
and
line
[
2
]
==
'transcript'
)
or
(
line
[
0
]
==
'While'
and
line
[
1
]
==
'talking'
and
line
[
2
]
==
'to'
)):
# Yes, found it!
break
errors
=
[]
found_a_line
=
0
warnings
=
0
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
sendmail_pattern
.
match
(
line
)
==
4
:
# Yes, an error/warning line. Ignore 4, remember 5, stop on rest
if
line
[
0
]
==
'5'
:
errors
.
append
(
line
)
elif
line
[
0
]
==
'4'
:
warnings
=
1
else
:
raise
Unparseable
line
=
string
.
split
(
line
)
if
line
and
line
[
0
][:
3
]
==
'---'
:
break
found_a_line
=
1
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
sendmail_pattern
.
match
(
line
)
==
4
:
# Yes, an error/warning line. Ignore 4, remember 5, stop on rest
if
line
[
0
]
==
'5'
:
errors
.
append
(
line
)
elif
line
[
0
]
==
'4'
:
warnings
=
1
else
:
raise
Unparseable
line
=
string
.
split
(
line
)
if
line
and
line
[
0
][:
3
]
==
'---'
:
break
found_a_line
=
1
# special case for CWI sendmail
if
len
(
line
)
>
1
and
line
[
1
]
==
'Undelivered'
:
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
string
.
strip
(
line
)
if
not
line
:
break
errors
.
append
(
line
+
': '
+
sub
)
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
string
.
strip
(
line
)
if
not
line
:
break
errors
.
append
(
line
+
': '
+
sub
)
# Empty transcripts are ok, others without an error are not.
if
found_a_line
and
not
(
errors
or
warnings
):
raise
Unparseable
raise
Unparseable
return
errors
def
emparse_cts
(
fp
,
sub
):
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
line
=
string
.
split
(
line
)
if
len
(
line
)
>
3
and
line
[
0
][:
2
]
==
'|-'
and
line
[
1
]
==
'Failed'
\
and
line
[
2
]
==
'addresses'
:
# Yes, found it!
break
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
line
=
string
.
split
(
line
)
if
len
(
line
)
>
3
and
line
[
0
][:
2
]
==
'|-'
and
line
[
1
]
==
'Failed'
\
and
line
[
2
]
==
'addresses'
:
# Yes, found it!
break
errors
=
[]
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
[:
2
]
==
'|-'
:
break
errors
.
append
(
line
)
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
[:
2
]
==
'|-'
:
break
errors
.
append
(
line
)
return
errors
def
emparse_aol
(
fp
,
sub
):
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
if
line
:
break
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
if
line
:
break
exp
=
'The mail you sent could not be delivered to:'
if
line
[:
len
(
exp
)]
!=
exp
:
raise
Unparseable
raise
Unparseable
errors
=
[]
while
1
:
line
=
fp
.
readline
()
if
sendmail_pattern
.
match
(
line
)
==
4
:
# Yes, an error/warning line. Ignore 4, remember 5, stop on rest
if
line
[
0
]
==
'5'
:
errors
.
append
(
line
)
elif
line
[
0
]
!=
'4'
:
raise
Unparseable
elif
line
==
'
\n
'
:
break
else
:
raise
Unparseable
line
=
fp
.
readline
()
if
sendmail_pattern
.
match
(
line
)
==
4
:
# Yes, an error/warning line. Ignore 4, remember 5, stop on rest
if
line
[
0
]
==
'5'
:
errors
.
append
(
line
)
elif
line
[
0
]
!=
'4'
:
raise
Unparseable
elif
line
==
'
\n
'
:
break
else
:
raise
Unparseable
return
errors
def
emparse_compuserve
(
fp
,
sub
):
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
if
line
:
break
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
if
line
:
break
exp
=
'Your message could not be delivered for the following reason:'
if
line
[:
len
(
exp
)]
!=
exp
:
raise
Unparseable
raise
Unparseable
errors
=
[]
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
if
line
[:
3
]
==
'---'
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
==
'Please resend your message at a later time.'
:
continue
line
=
'Compuserve: '
+
line
errors
.
append
(
line
)
line
=
fp
.
readline
()
if
not
line
:
break
if
line
[:
3
]
==
'---'
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
==
'Please resend your message at a later time.'
:
continue
line
=
'Compuserve: '
+
line
errors
.
append
(
line
)
return
errors
prov_pattern
=
regex
.
compile
(
'.* |
\
(.*
\
)'
)
def
emparse_providence
(
fp
,
sub
):
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
exp
=
'The following errors occurred'
if
line
[:
len
(
exp
)]
==
exp
:
break
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
exp
=
'The following errors occurred'
if
line
[:
len
(
exp
)]
==
exp
:
break
errors
=
[]
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
[:
4
]
==
'----'
:
break
if
prov_pattern
.
match
(
line
)
>
0
:
errors
.
append
(
prov_pattern
.
group
(
1
))
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
[:
4
]
==
'----'
:
break
if
prov_pattern
.
match
(
line
)
>
0
:
errors
.
append
(
prov_pattern
.
group
(
1
))
if
not
errors
:
raise
Unparseable
raise
Unparseable
return
errors
def
emparse_x400
(
fp
,
sub
):
exp
=
'This report relates to your message:'
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
if
line
[:
len
(
exp
)]
==
exp
:
break
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
if
line
[:
len
(
exp
)]
==
exp
:
break
errors
=
[]
exp
=
'Your message was not delivered to'
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
[:
len
(
exp
)]
==
exp
:
error
=
string
.
strip
(
line
[
len
(
exp
):])
sep
=
': '
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
break
if
line
[
0
]
==
' '
and
line
[
-
1
]
!=
':'
:
error
=
error
+
sep
+
string
.
strip
(
line
)
sep
=
'; '
errors
.
append
(
error
)
return
errors
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
continue
if
line
[:
len
(
exp
)]
==
exp
:
error
=
string
.
strip
(
line
[
len
(
exp
):])
sep
=
': '
while
1
:
line
=
fp
.
readline
()
if
not
line
:
break
line
=
line
[:
-
1
]
if
not
line
:
break
if
line
[
0
]
==
' '
and
line
[
-
1
]
!=
':'
:
error
=
error
+
sep
+
string
.
strip
(
line
)
sep
=
'; '
errors
.
append
(
error
)
return
errors
raise
Unparseable
def
emparse_passau
(
fp
,
sub
):
exp
=
'Unable to deliver message because'
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
if
line
[:
len
(
exp
)]
==
exp
:
break
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
if
line
[:
len
(
exp
)]
==
exp
:
break
errors
=
[]
exp
=
'Returned Text follows'
while
1
:
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
if
not
line
:
continue
if
line
[:
len
(
exp
)]
==
exp
:
return
errors
errors
.
append
(
string
.
strip
(
line
))
line
=
fp
.
readline
()
if
not
line
:
raise
Unparseable
line
=
line
[:
-
1
]
# Check that we're not in the returned message yet
if
string
.
lower
(
line
)[:
5
]
==
'from:'
:
raise
Unparseable
if
not
line
:
continue
if
line
[:
len
(
exp
)]
==
exp
:
return
errors
errors
.
append
(
string
.
strip
(
line
))
EMPARSERS
=
[
emparse_sendmail
,
emparse_aol
,
emparse_cts
,
emparse_compuserve
,
emparse_providence
,
emparse_x400
,
emparse_passau
]
emparse_providence
,
emparse_x400
,
emparse_passau
]
def
sort_numeric
(
a
,
b
):
a
=
string
.
atoi
(
a
)
...
...
@@ -290,62 +292,62 @@ def parsedir(dir, modify):
files
.
sort
(
sort_numeric
)
for
fn
in
files
:
# Lets try to parse the file.
fp
=
open
(
fn
)
m
=
ErrorMessage
(
fp
)
sender
=
m
.
getaddr
(
'From'
)
print
'
%
s
\t
%-40
s
\t
'
%
(
fn
,
sender
[
1
]),
# Lets try to parse the file.
fp
=
open
(
fn
)
m
=
ErrorMessage
(
fp
)
sender
=
m
.
getaddr
(
'From'
)
print
'
%
s
\t
%-40
s
\t
'
%
(
fn
,
sender
[
1
]),
if
m
.
is_warning
():
print
'warning only'
nwarn
=
nwarn
+
1
if
modify
:
os
.
unlink
(
fn
)
continue
if
m
.
is_warning
():
print
'warning only'
nwarn
=
nwarn
+
1
if
modify
:
os
.
unlink
(
fn
)
continue
try
:
errors
=
m
.
get_errors
()
except
Unparseable
:
print
'** Not parseable'
nbad
=
nbad
+
1
continue
print
len
(
errors
),
'errors'
try
:
errors
=
m
.
get_errors
()
except
Unparseable
:
print
'** Not parseable'
nbad
=
nbad
+
1
continue
print
len
(
errors
),
'errors'
# Remember them
for
e
in
errors
:
try
:
mm
,
dd
=
m
.
getdate
(
'date'
)[
1
:
1
+
2
]
date
=
'
%
s
%02
d'
%
(
calendar
.
month_abbr
[
mm
],
dd
)
except
:
date
=
'??????'
if
not
errordict
.
has_key
(
e
):
errordict
[
e
]
=
1
errorfirst
[
e
]
=
'
%
s (
%
s)'
%
(
fn
,
date
)
else
:
errordict
[
e
]
=
errordict
[
e
]
+
1
errorlast
[
e
]
=
'
%
s (
%
s)'
%
(
fn
,
date
)
# Remember them
for
e
in
errors
:
try
:
mm
,
dd
=
m
.
getdate
(
'date'
)[
1
:
1
+
2
]
date
=
'
%
s
%02
d'
%
(
calendar
.
month_abbr
[
mm
],
dd
)
except
:
date
=
'??????'
if
not
errordict
.
has_key
(
e
):
errordict
[
e
]
=
1
errorfirst
[
e
]
=
'
%
s (
%
s)'
%
(
fn
,
date
)
else
:
errordict
[
e
]
=
errordict
[
e
]
+
1
errorlast
[
e
]
=
'
%
s (
%
s)'
%
(
fn
,
date
)
nok
=
nok
+
1
if
modify
:
os
.
unlink
(
fn
)
nok
=
nok
+
1
if
modify
:
os
.
unlink
(
fn
)
print
'--------------'
print
nok
,
'files parsed,'
,
nwarn
,
'files warning-only,'
,
print
nbad
,
'files unparseable'
print
'--------------'
for
e
in
errordict
.
keys
():
print
errordict
[
e
],
errorfirst
[
e
],
'-'
,
errorlast
[
e
],
'
\t
'
,
e
print
errordict
[
e
],
errorfirst
[
e
],
'-'
,
errorlast
[
e
],
'
\t
'
,
e
def
main
():
modify
=
0
if
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'-d'
:
modify
=
1
del
sys
.
argv
[
1
]
modify
=
1
del
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
>
1
:
for
folder
in
sys
.
argv
[
1
:]:
parsedir
(
folder
,
modify
)
for
folder
in
sys
.
argv
[
1
:]:
parsedir
(
folder
,
modify
)
else
:
parsedir
(
'/ufs/jack/Mail/errorsinbox'
,
modify
)
parsedir
(
'/ufs/jack/Mail/errorsinbox'
,
modify
)
if
__name__
==
'__main__'
or
sys
.
argv
[
0
]
==
__name__
:
main
()
Tools/scripts/treesync.py
Dosyayı görüntüle @
ed5b3d8b
...
...
@@ -12,11 +12,11 @@ entry in the master tree are synchronized. This means:
If the files differ:
if the slave file is newer:
normalize the slave file
if the files still differ:
copy the slave to the master
else (the master is newer):
copy the master to the slave
normalize the slave file
if the files still differ:
copy the slave to the master
else (the master is newer):
copy the master to the slave
normalizing the slave means replacing CRLF with LF when the master
doesn't use CRLF
...
...
@@ -37,107 +37,107 @@ def main():
global
create_directories
,
write_master
,
write_slave
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"nym:s:d:f:a:"
)
for
o
,
a
in
opts
:
if
o
==
'-y'
:
default_answer
=
"yes"
if
o
==
'-n'
:
default_answer
=
"no"
if
o
==
'-s'
:
write_slave
=
a
if
o
==
'-m'
:
write_master
=
a
if
o
==
'-d'
:
create_directories
=
a
if
o
==
'-f'
:
create_files
=
a
if
o
==
'-a'
:
create_files
=
create_directories
=
write_slave
=
write_master
=
a
if
o
==
'-y'
:
default_answer
=
"yes"
if
o
==
'-n'
:
default_answer
=
"no"
if
o
==
'-s'
:
write_slave
=
a
if
o
==
'-m'
:
write_master
=
a
if
o
==
'-d'
:
create_directories
=
a
if
o
==
'-f'
:
create_files
=
a
if
o
==
'-a'
:
create_files
=
create_directories
=
write_slave
=
write_master
=
a
try
:
[
slave
,
master
]
=
args
[
slave
,
master
]
=
args
except
ValueError
:
print
"usage: python"
,
sys
.
argv
[
0
]
or
"treesync.py"
,
print
"[-n] [-y] [-m y|n|a] [-s y|n|a] [-d y|n|a] [-f n|y|a]"
,
print
"slavedir masterdir"
return
print
"usage: python"
,
sys
.
argv
[
0
]
or
"treesync.py"
,
print
"[-n] [-y] [-m y|n|a] [-s y|n|a] [-d y|n|a] [-f n|y|a]"
,
print
"slavedir masterdir"
return
process
(
slave
,
master
)
def
process
(
slave
,
master
):
cvsdir
=
os
.
path
.
join
(
master
,
"CVS"
)
if
not
os
.
path
.
isdir
(
cvsdir
):
print
"skipping master subdirectory"
,
master
print
"-- not under CVS"
return
print
"skipping master subdirectory"
,
master
print
"-- not under CVS"
return
print
"-"
*
40
print
"slave "
,
slave
print
"master"
,
master
if
not
os
.
path
.
isdir
(
slave
):
if
not
okay
(
"create slave directory
%
s?"
%
slave
,
answer
=
create_directories
):
print
"skipping master subdirectory"
,
master
print
"-- no corresponding slave"
,
slave
return
print
"creating slave directory"
,
slave
try
:
os
.
mkdir
(
slave
)
except
os
.
error
,
msg
:
print
"can't make slave directory"
,
slave
,
":"
,
msg
return
else
:
print
"made slave directory"
,
slave
if
not
okay
(
"create slave directory
%
s?"
%
slave
,
answer
=
create_directories
):
print
"skipping master subdirectory"
,
master
print
"-- no corresponding slave"
,
slave
return
print
"creating slave directory"
,
slave
try
:
os
.
mkdir
(
slave
)
except
os
.
error
,
msg
:
print
"can't make slave directory"
,
slave
,
":"
,
msg
return
else
:
print
"made slave directory"
,
slave
cvsdir
=
None
subdirs
=
[]
names
=
os
.
listdir
(
master
)
for
name
in
names
:
mastername
=
os
.
path
.
join
(
master
,
name
)
slavename
=
os
.
path
.
join
(
slave
,
name
)
if
name
==
"CVS"
:
cvsdir
=
mastername
else
:
if
os
.
path
.
isdir
(
mastername
)
and
not
os
.
path
.
islink
(
mastername
):
subdirs
.
append
((
slavename
,
mastername
))
mastername
=
os
.
path
.
join
(
master
,
name
)
slavename
=
os
.
path
.
join
(
slave
,
name
)
if
name
==
"CVS"
:
cvsdir
=
mastername
else
:
if
os
.
path
.
isdir
(
mastername
)
and
not
os
.
path
.
islink
(
mastername
):
subdirs
.
append
((
slavename
,
mastername
))
if
cvsdir
:
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
)
.
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
s
=
os
.
path
.
join
(
slave
,
name
)
m
=
os
.
path
.
join
(
master
,
name
)
compare
(
s
,
m
)
entries
=
os
.
path
.
join
(
cvsdir
,
"Entries"
)
for
e
in
open
(
entries
)
.
readlines
():
words
=
string
.
split
(
e
,
'/'
)
if
words
[
0
]
==
''
and
words
[
1
:]:
name
=
words
[
1
]
s
=
os
.
path
.
join
(
slave
,
name
)
m
=
os
.
path
.
join
(
master
,
name
)
compare
(
s
,
m
)
for
(
s
,
m
)
in
subdirs
:
process
(
s
,
m
)
process
(
s
,
m
)
def
compare
(
slave
,
master
):
try
:
sf
=
open
(
slave
,
'r'
)
sf
=
open
(
slave
,
'r'
)
except
IOError
:
sf
=
None
sf
=
None
try
:
mf
=
open
(
master
,
'rb'
)
mf
=
open
(
master
,
'rb'
)
except
IOError
:
mf
=
None
mf
=
None
if
not
sf
:
if
not
mf
:
print
"Neither master nor slave exists"
,
master
return
print
"Creating missing slave"
,
slave
copy
(
master
,
slave
,
answer
=
create_files
)
return
if
not
mf
:
print
"Neither master nor slave exists"
,
master
return
print
"Creating missing slave"
,
slave
copy
(
master
,
slave
,
answer
=
create_files
)
return
if
not
mf
:
print
"Not updating missing master"
,
master
return
print
"Not updating missing master"
,
master
return
if
sf
and
mf
:
if
identical
(
sf
,
mf
):
return
if
identical
(
sf
,
mf
):
return
sft
=
mtime
(
sf
)
mft
=
mtime
(
mf
)
if
mft
>
sft
:
# Master is newer -- copy master to slave
sf
.
close
()
mf
.
close
()
print
"Master "
,
master
print
"is newer than slave"
,
slave
copy
(
master
,
slave
,
answer
=
write_slave
)
return
# Master is newer -- copy master to slave
sf
.
close
()
mf
.
close
()
print
"Master "
,
master
print
"is newer than slave"
,
slave
copy
(
master
,
slave
,
answer
=
write_slave
)
return
# Slave is newer -- copy slave to master
print
"Slave is"
,
sft
-
mft
,
"seconds newer than master"
# But first check what to do about CRLF
...
...
@@ -146,20 +146,20 @@ def compare(slave, master):
mf
.
close
()
sf
.
close
()
if
fun
:
print
"***UPDATING MASTER (BINARY COPY)***"
copy
(
slave
,
master
,
"rb"
,
answer
=
write_master
)
print
"***UPDATING MASTER (BINARY COPY)***"
copy
(
slave
,
master
,
"rb"
,
answer
=
write_master
)
else
:
print
"***UPDATING MASTER***"
copy
(
slave
,
master
,
"r"
,
answer
=
write_master
)
print
"***UPDATING MASTER***"
copy
(
slave
,
master
,
"r"
,
answer
=
write_master
)
BUFSIZE
=
16
*
1024
def
identical
(
sf
,
mf
):
while
1
:
sd
=
sf
.
read
(
BUFSIZE
)
md
=
mf
.
read
(
BUFSIZE
)
if
sd
!=
md
:
return
0
if
not
sd
:
break
sd
=
sf
.
read
(
BUFSIZE
)
md
=
mf
.
read
(
BUFSIZE
)
if
sd
!=
md
:
return
0
if
not
sd
:
break
return
1
def
mtime
(
f
):
...
...
@@ -168,36 +168,36 @@ def mtime(f):
def
funnychars
(
f
):
while
1
:
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
if
'
\r
'
in
buf
or
'
\0
'
in
buf
:
return
1
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
if
'
\r
'
in
buf
or
'
\0
'
in
buf
:
return
1
return
0
def
copy
(
src
,
dst
,
rmode
=
"rb"
,
wmode
=
"wb"
,
answer
=
'ask'
):
print
"copying"
,
src
print
" to"
,
dst
if
not
okay
(
"okay to copy? "
,
answer
):
return
return
f
=
open
(
src
,
rmode
)
g
=
open
(
dst
,
wmode
)
while
1
:
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
g
.
write
(
buf
)
buf
=
f
.
read
(
BUFSIZE
)
if
not
buf
:
break
g
.
write
(
buf
)
f
.
close
()
g
.
close
()
def
okay
(
prompt
,
answer
=
'ask'
):
answer
=
string
.
lower
(
string
.
strip
(
answer
))
if
not
answer
or
answer
[
0
]
not
in
'ny'
:
answer
=
raw_input
(
prompt
)
answer
=
string
.
lower
(
string
.
strip
(
answer
))
if
not
answer
:
answer
=
default_answer
answer
=
raw_input
(
prompt
)
answer
=
string
.
lower
(
string
.
strip
(
answer
))
if
not
answer
:
answer
=
default_answer
if
answer
[:
1
]
==
'y'
:
return
1
return
1
if
answer
[:
1
]
==
'n'
:
return
0
return
0
print
"Yes or No please -- try again:"
return
okay
(
prompt
)
...
...
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