Mercurial > hg > cc > cirrus_work
changeset 332:83450325421f trim
not working yet
| author | Henry S. Thompson <ht@inf.ed.ac.uk> |
|---|---|
| date | Sat, 28 Feb 2026 14:48:32 +0000 |
| parents | 191127a9a663 |
| children | 282a35927943 |
| files | results/CC-MAIN-2019-35/warc_lmhx/mcdb/idx/tcb.py |
| diffstat | 1 files changed, 50 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 + +
