4 import manga.lib, manga.profile
7 out.write("usage: checkmanga [-hSi] [-p PROFILE] TAG\n")
11 opts, args = getopt.getopt(sys.argv[1:], "hSip:")
23 profile = manga.profile.profile.last()
25 profile = manga.profile.profile.byname(prnm)
33 fp = pr.file("lastpages")
39 words = manga.profile.splitline(ln)
40 ret[tuple(words[:2])] = [int(x) for x in words[2:]]
43 def savepages(pr, pages):
44 with pr.file("lastpages", "w") as fp:
45 for (libnm, id), pl in pages.iteritems():
46 fp.write(manga.profile.consline(libnm, id, *[str(x) for x in pl]) + "\n")
49 with open("/dev/tty", "r+") as tp:
50 tp.write(q); tp.flush()
51 return tp.readline().strip()
55 while isinstance(m, manga.lib.pagelist):
56 ret.append(len(m) - 1)
60 lastpages = getpages(profile)
63 for mp in profile.bytag(tag):
68 sys.stderr.write("checkmanga: could not open %s/%s\n" % (libnm, id))
72 if (mp.libnm, mp.id) in lastpages:
73 clp = lastpages[mp.libnm, mp.id]
83 sys.stdout.write("%s %s: %s\n" % (mp.libnm, mp.id, str(clpn)))
86 sys.stdout.write("%s %s: structure changed\n" % (mp.libnm, mp.id))
89 sys.stdout.write("%s %s: not previously checked\n" % (mp.libnm, mp.id))
96 if prompt("Save? ")[:1].lower() == "y":
99 lastpages[mp.libnm, mp.id] = nlp
102 sys.stderr.write("checkmanga: unexpected error when checking %s/%s:\n" % (mp.libnm, mp.id))
105 savepages(profile, lastpages)