From cbf8a2a65928694202e19b6bcf56ec84bcbf613c Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 8 Dec 2012 02:02:25 +0100 Subject: Reorganize source tree and files installation location, cleanup setup.py (Closes: #689409) --- lib/misc.py | 63 ------------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 lib/misc.py (limited to 'lib/misc.py') diff --git a/lib/misc.py b/lib/misc.py deleted file mode 100644 index d084861..0000000 --- a/lib/misc.py +++ /dev/null @@ -1,63 +0,0 @@ -''' - Care about misc formats -''' - -import parser - -from bencode import bencode - - -class TorrentStripper(parser.GenericParser): - ''' - Represent a torrent file with the help - of the bencode lib from Petru Paler - ''' - def __init__(self, filename, parser, mime, backup, add2archive): - super(TorrentStripper, self).__init__(filename, parser, mime, - backup, add2archive) - self.fields = ['comment', 'creation date', 'created by'] - - def is_clean(self): - ''' - Check if the file is clean from harmful metadatas - ''' - with open(self.filename, 'r') as f: - decoded = bencode.bdecode(f.read()) - for key in self.fields: - try: - if decoded[key] != '': - return False - except: - pass - return True - - def get_meta(self): - ''' - Return a dict with all the meta of the file - ''' - metadata = {} - with open(self.filename, 'r') as f: - decoded = bencode.bdecode(f.read()) - for key in self.fields: - try: - if decoded[key] != '': - metadata[key] = decoded[key] - except: - pass - return metadata - - def remove_all(self): - ''' - Remove all the files that are compromizing - ''' - with open(self.filename, 'r') as f: - decoded = bencode.bdecode(f.read()) - for key in self.fields: - try: - decoded[key] = '' - except: - pass - with open(self.output, 'w') as f: # encode the decoded torrent - f.write(bencode.bencode(decoded)) # and write it in self.output - self.do_backup() - return True -- cgit v1.3