upgrade to python3;add some validator examples

This commit is contained in:
2025-10-11 12:33:24 +08:00
parent 65632f0e60
commit 487c041148
25 changed files with 1492 additions and 317 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import sys, string, hashlib, os
from stat import *
@@ -9,9 +9,9 @@ def check_file(name, size, md5sum):
m = hashlib.md5()
if os.path.isfile(name):
s = os.stat(name)[ST_SIZE]
if s == string.atoi(size):
if s == int(size):
f = open(name, 'rb')
m.update(f.read(string.atoi(size)))
m.update(f.read(int(size)))
f.close()
d = m.hexdigest()
result.write("%s %d %s\n" % (name, s, d))
@@ -26,9 +26,10 @@ if __name__ == '__main__':
result = open(sys.argv[3], 'w+')
fstdout = open(sys.argv[2], 'r')
for line in fstdout:
name, size, md5sum = string.split(string.strip(line), ' ')
name, size, md5sum = line.strip().split(' ')
if not check_file(name, size, md5sum):
print 'WA'; break
print('WA')
break
fstdout.close()
result.close()
print 'AC'
print('AC')