Blame | Last modification | View Log | Download
# Written by John Hoffman# see LICENSE.txt for license informationfrom binascii import unhexlifytry:Trueexcept:True = 1False = 0# parses a list of torrent hashes, in the format of one hash per line in hex formatdef parsetorrentlist(filename, parsed):new_parsed = {}added = {}removed = parsedf = open(filename, 'r')while True:l = f.readline()if not l:breakl = l.strip()try:if len(l) != 40:raise ValueError, 'bad line'h = unhexlify(l)except:print '*** WARNING *** could not parse line in torrent list: '+lif parsed.has_key(h):del removed[h]else:added[h] = Truenew_parsed[h] = Truef.close()return (new_parsed, added, removed)