def is_torrent_file(metafilepath):
 with open(metafilepath, u'rb') as f:
  data = f.read(200)
 magic_marker = bool(TORRENT_RE.match(data))
 if (not magic_marker):
  log.trace((u"%s doesn't seem to be a torrent, got `%s` (hex)" % (metafilepath, binascii.hexlify(data))))
 return bool(magic_marker)

def is_torrent_file ( metafilepath ) : with open ( metafilepath , u'rb' ) as f : data = f . read ( 200 ) magic_marker = bool ( TORRENT_RE . match ( data ) ) if ( not magic_marker ) : log . trace ( ( u"%s doesn't seem to be a torrent, got `%s` (hex)" % ( metafilepath , binascii . hexlify ( data ) ) ) ) return bool ( magic_marker )
check whether a file looks like a metafile by peeking into its content .