[Pkg-privacy-commits] [mat] 32/68: Improves the way torrents are handled

Sascha Steinbiss sascha at steinbiss.name
Sun Jan 3 12:32:40 UTC 2016


This is an automated email from the git hooks/post-receive script.

sascha-guest pushed a commit to branch master
in repository mat.

commit 8b181c6ca5c6fc699efbd6ff3f68e87401ae8ab5
Author: jvoisin <julien.voisin at dustri.org>
Date:   Wed Dec 2 17:40:05 2015 +0100

    Improves the way torrents are handled
    
    This commit makes metadata removal of torrents recursive.
    It's close to useless, because I haven't seen any torrent with a
    recursive structure, but the documentation says that it can happen, and
    the method was already implemented, so better safe than sorry.
---
 libmat/misc.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libmat/misc.py b/libmat/misc.py
index cc480e5..e5db06d 100644
--- a/libmat/misc.py
+++ b/libmat/misc.py
@@ -54,8 +54,10 @@ class TorrentStripper(parser.GenericParser):
         """ Remove recursively all compromizing fields
         """
         d = dict()
-        for i, j in [i for i in list(dictionary.items()) if i in self.fields]:
-            if isinstance(j, dict):
+        for i, j in list(dictionary.items()):
+            if not i in self.fields:
+                continue
+            elif isinstance(j, dict):
                 d = dict(list(d.items()) + list(self.__get_meta_recursively(j).items()))
             else:
                 d[i] = j
@@ -67,7 +69,7 @@ class TorrentStripper(parser.GenericParser):
         with open(self.filename, 'r') as f:
             decoded = bencode.bdecode(f.read())
 
-        cleaned = {i: j for i, j in list(decoded.items()) if i in self.fields}
+        cleaned = self.__remove_all_recursively(decoded)
 
         with open(self.output, 'w') as f:  # encode the decoded torrent
             f.write(bencode.bencode(cleaned))  # and write it in self.output

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/mat.git



More information about the Pkg-privacy-commits mailing list