~ubuntu-branches/ubuntu/oneiric/bittornado/oneiric

« back to all changes in this revision

Viewing changes to BitTornado/BT1/StreamCheck.py

  • Committer: Bazaar Package Importer
  • Author(s): Cameron Dale
  • Date: 2010-03-21 14:36:30 UTC
  • Revision ID: james.westby@ubuntu.com-20100321143630-d1zk1zdasaf8125s
Tags: 0.3.18-10
* New patch from upstream's CVS to allow torrents that only have an
  announce list: 30_announce_list_only_torrents.dpatch (Closes: #551766)
* Fix a lot of lintian warnings
  - Update standards version to 3.8.4 (no changes)
* Fix for when compact_reqd is turned off:
  31_fix_for_compact_reqd_off.dpatch (Closes: #574860)
* Switch to the new "3.0 (quilt)" source format

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
def toint(s):
23
23
    return long(b2a_hex(s), 16)
24
24
 
25
 
def tobinary(i):
26
 
    return (chr(i >> 24) + chr((i >> 16) & 0xFF) + 
27
 
        chr((i >> 8) & 0xFF) + chr(i & 0xFF))
28
 
 
29
 
hexchars = '0123456789ABCDEF'
30
 
hexmap = []
31
 
for i in xrange(256):
32
 
    hexmap.append(hexchars[(i&0xF0)/16]+hexchars[i&0x0F])
33
 
 
34
25
def tohex(s):
35
 
    r = []
36
 
    for c in s:
37
 
        r.append(hexmap[ord(c)])
38
 
    return ''.join(r)
 
26
    return b2a_hex(s).upper()
39
27
 
40
28
def make_readable(s):
41
29
    if not s:
44
32
        return tohex(s)
45
33
    return '"'+s+'"'
46
34
   
47
 
def toint(s):
48
 
    return long(b2a_hex(s), 16)
49
 
 
50
35
# header, reserved, download id, my id, [length, message]
51
36
 
52
37
streamno = 0