[Pkg-privacy-commits] [mat] 03/68: Some minors pep8 modifications
Sascha Steinbiss
sascha at steinbiss.name
Sun Jan 3 12:32:37 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 f5a39ac0b6ddc9154b1b1b55d255074d6dd4eecd
Author: jvoisin <julien.voisin at dustri.org>
Date: Mon Nov 2 18:18:22 2015 +0100
Some minors pep8 modifications
---
libmat/archive.py | 9 +++++++++
libmat/exceptions.py | 1 +
libmat/mat.py | 5 +++--
libmat/misc.py | 1 -
libmat/mutagenstripper.py | 4 ++++
libmat/office.py | 2 ++
libmat/parser.py | 3 ++-
7 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/libmat/archive.py b/libmat/archive.py
index 8a3fee9..426dcf9 100644
--- a/libmat/archive.py
+++ b/libmat/archive.py
@@ -44,6 +44,7 @@ class GenericArchiveStripper(parser.GenericParser):
def is_clean(self, list_unsupported=False):
""" Virtual method to check for harmul metadata
+ :param bool list_unsupported:
"""
raise NotImplementedError
@@ -157,6 +158,10 @@ class ZipStripper(GenericArchiveStripper):
files starting with "begining_blacklist", or ending with
"ending_blacklist". This method also add files present in
whitelist to the archive.
+
+ :param list whitelist: Add those files to the produced archive, regardless if they are harmful or not
+ :param list beginning_blacklist: If the file starts with $ending_blacklist, it will _not_ be added
+ :param list ending_blacklist: If the file end with $ending_blacklist, it will _not_ be added
"""
if not ending_blacklist:
ending_blacklist = []
@@ -222,6 +227,8 @@ class TarStripper(GenericArchiveStripper):
""" Remove all harmful metadata from the tarfile.
The method will also add every files matching
whitelist in the produced archive.
+ :param list whitelist: Files to add the to produced archive,
+ regardless if they are considered harmfull.
"""
if not whitelist:
whitelist = []
@@ -257,6 +264,7 @@ class TarStripper(GenericArchiveStripper):
@staticmethod
def is_file_clean(current_file):
""" Check metadatas added by tarfile
+ :param tarfile.TarInfo current_file:
"""
if current_file.mtime != 0:
return False
@@ -275,6 +283,7 @@ class TarStripper(GenericArchiveStripper):
When list_unsupported is True, the method returns a list
of all non-supported/archives files contained in the
archive.
+ :param bool list_unsupported:
"""
ret_list = []
tarin = tarfile.open(self.filename, 'r' + self.compression)
diff --git a/libmat/exceptions.py b/libmat/exceptions.py
index e71c398..d982d2d 100644
--- a/libmat/exceptions.py
+++ b/libmat/exceptions.py
@@ -7,6 +7,7 @@ class UnableToRemoveFile(Exception):
"""
pass
+
class UnableToWriteFile(Exception):
"""This exception is raised when a file
can could not be chmod +w
diff --git a/libmat/mat.py b/libmat/mat.py
index 5b5a83c..3947606 100644
--- a/libmat/mat.py
+++ b/libmat/mat.py
@@ -9,7 +9,6 @@ import os
import platform
import subprocess
import xml.sax
-import mimetypes
import hachoir_core.cmd_line
import hachoir_parser
@@ -46,7 +45,8 @@ def get_logo():
def get_datafile_path(filename):
- """ Return the path to the given ressource
+ """ Return the path to $filename
+ :param string filename:
"""
if os.path.isfile(os.path.join(os.path.curdir, 'data', filename)):
return os.path.join(os.path.curdir, 'data', filename)
@@ -82,6 +82,7 @@ class XMLParser(xml.sax.handler.ContentHandler):
"""
def __init__(self):
+ xml.sax.handler.ContentHandler.__init__(self)
self.dict = {}
self.list = []
self.content, self.key = '', ''
diff --git a/libmat/misc.py b/libmat/misc.py
index b1a551c..a55b8ed 100644
--- a/libmat/misc.py
+++ b/libmat/misc.py
@@ -64,7 +64,6 @@ class TorrentStripper(parser.GenericParser):
def remove_all(self):
""" Remove all comprimizing fields
"""
- decoded = ''
with open(self.filename, 'r') as f:
decoded = bencode.bdecode(f.read())
diff --git a/libmat/mutagenstripper.py b/libmat/mutagenstripper.py
index be89178..7e4beed 100644
--- a/libmat/mutagenstripper.py
+++ b/libmat/mutagenstripper.py
@@ -5,17 +5,21 @@ import parser
class MutagenStripper(parser.GenericParser):
+ """ Parser using the (awesome) mutagen library. """
def __init__(self, filename, parser, mime, backup, is_writable, **kwargs):
super(MutagenStripper, self).__init__(filename, parser, mime, backup, is_writable, **kwargs)
+ self.mfile = None # This will be instanciated in self._create_mfile()
self._create_mfile()
def _create_mfile(self):
raise NotImplementedError
def is_clean(self):
+ """ Check if the file is clean. """
return not self.mfile.tags
def remove_all(self):
+ """ Remove all harmful metadata. """
if self.backup:
self.create_backup_copy()
self.mfile.delete()
diff --git a/libmat/office.py b/libmat/office.py
index bd4bd97..5a57b57 100644
--- a/libmat/office.py
+++ b/libmat/office.py
@@ -77,6 +77,8 @@ class OpenXmlStripper(archive.TerminalZipStripper):
"""
def remove_all(self):
+ """ Remove harmful metadata, by deleting everything that doesn't end with '.rels' in the
+ 'docProps' folder. """
return super(OpenXmlStripper, self).remove_all(
beginning_blacklist='docProps/', whitelist='.rels')
diff --git a/libmat/parser.py b/libmat/parser.py
index 43de6d6..c6ba0a4 100644
--- a/libmat/parser.py
+++ b/libmat/parser.py
@@ -85,7 +85,8 @@ class GenericParser(object):
except:
return False
- def _remove(self, fieldset, field):
+ @staticmethod
+ def _remove(fieldset, field):
""" Delete the given field
"""
del fieldset[field]
--
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