Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
# Written by John Hoffman
2
# see LICENSE.txt for license information
3
 
4
from binascii import unhexlify
5
 
6
try:
7
    True
8
except:
9
    True = 1
10
    False = 0
11
 
12
 
13
# parses a list of torrent hashes, in the format of one hash per line in hex format
14
 
15
def parsetorrentlist(filename, parsed):
16
    new_parsed = {}
17
    added = {}
18
    removed = parsed
19
    f = open(filename, 'r')
20
    while True:
21
        l = f.readline()
22
        if not l:
23
            break
24
        l = l.strip()
25
        try:
26
            if len(l) != 40:
27
                raise ValueError, 'bad line'
28
            h = unhexlify(l)
29
        except:
30
            print '*** WARNING *** could not parse line in torrent list: '+l
31
        if parsed.has_key(h):
32
            del removed[h]
33
        else:
34
            added[h] = True
35
        new_parsed[h] = True
36
    f.close()
37
    return (new_parsed, added, removed)
38