# HG changeset patch # User Henry S. Thompson # Date 1772290112 0 # Node ID 83450325421fd457910d98e841347fce1d307294 # Parent 191127a9a663b62547bd618a31f2b8b4074d633e not working yet diff -r 191127a9a663 -r 83450325421f results/CC-MAIN-2019-35/warc_lmhx/mcdb/idx/tcb.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/results/CC-MAIN-2019-35/warc_lmhx/mcdb/idx/tcb.py Sat Feb 28 14:48:32 2026 +0000 @@ -0,0 +1,50 @@ +import sys,os + +def init(): + global i, year, count, cur_status, years, nyears, res_dir, ff + + i = 0 + year = 1995 + count = 0 + cur_status = 0 + + with open("%s/results/CC-MAIN-2019-35/warc_lmhx/years.txt"%os.getenv("HOME"),"r") \ + as yf: + years=[int(l) for l in yf] + + nyears = len(years) + ff = [None] * (nyears + 1) + res_dir = sys.argv.pop(1) + ff[nyears] = open("%s/oob"%res_dir,"bw") + +def finish(): + global ff, i, count, cur_status + ff[i].write(b'%d\t%d\n'%(count, cur_status)) + +def cbf(status,lastmod): + global cur_status, count, i, year, nyears + stat = int(status) + lm = int(lastmod) + print(i, year, cur_status, count, stat, lm, file = sys.stderr) + while (not year == 0) and (lm > years[i]): + # change of year + if count != 0: + ff[i].write(b'%s\t%d\n'%(count, cur_status)) + if i < nyears: + i += 1 + year += 1 + count = 0 + cur_status = 0 + if i == nyears: + year = 0 + break + if not ff[i]: + ff[i] = open("%s/%s"%(res_dir, year),"bw") + if stat == cur_status: + count += 1 + else: + ff[i].write(b'%d\t%d\n'%(count, cur_status)) + cur_status = stat + count = 1 + +