summaryrefslogtreecommitdiff
path: root/libmat2/torrent.py
diff options
context:
space:
mode:
authorBrolf2019-02-20 00:45:27 +0100
committergeorg2019-03-05 23:13:42 +0000
commit5ac91cd4f94a822c81bd0bc55a2f7034b31eee7a (patch)
treeb8e4e9ebb15757d5a6779eb5c224a6f98ba01ead /libmat2/torrent.py
parentc3f097a82ba6fd8549aabc9c5427ab4e337fec0e (diff)
Refactor {black,white}list into {block,allow}list
Closes #96
Diffstat (limited to 'libmat2/torrent.py')
-rw-r--r--libmat2/torrent.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/libmat2/torrent.py b/libmat2/torrent.py
index c006f9c..6021d75 100644
--- a/libmat2/torrent.py
+++ b/libmat2/torrent.py
@@ -6,7 +6,7 @@ from . import abstract
6 6
7class TorrentParser(abstract.AbstractParser): 7class TorrentParser(abstract.AbstractParser):
8 mimetypes = {'application/x-bittorrent', } 8 mimetypes = {'application/x-bittorrent', }
9 whitelist = {b'announce', b'announce-list', b'info'} 9 allowlist = {b'announce', b'announce-list', b'info'}
10 10
11 def __init__(self, filename): 11 def __init__(self, filename):
12 super().__init__(filename) 12 super().__init__(filename)
@@ -18,14 +18,14 @@ class TorrentParser(abstract.AbstractParser):
18 def get_meta(self) -> Dict[str, Union[str, dict]]: 18 def get_meta(self) -> Dict[str, Union[str, dict]]:
19 metadata = {} 19 metadata = {}
20 for key, value in self.dict_repr.items(): 20 for key, value in self.dict_repr.items():
21 if key not in self.whitelist: 21 if key not in self.allowlist:
22 metadata[key.decode('utf-8')] = value 22 metadata[key.decode('utf-8')] = value
23 return metadata 23 return metadata
24 24
25 def remove_all(self) -> bool: 25 def remove_all(self) -> bool:
26 cleaned = dict() 26 cleaned = dict()
27 for key, value in self.dict_repr.items(): 27 for key, value in self.dict_repr.items():
28 if key in self.whitelist: 28 if key in self.allowlist:
29 cleaned[key] = value 29 cleaned[key] = value
30 with open(self.output_filename, 'wb') as f: 30 with open(self.output_filename, 'wb') as f:
31 f.write(_BencodeHandler().bencode(cleaned)) 31 f.write(_BencodeHandler().bencode(cleaned))