From 2212039d70ce5c4e97c3943bb82d4231c10e1260 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 25 Nov 2015 19:29:18 +0100 Subject: Make the logging more pep-282 compliant See https://www.python.org/dev/peps/pep-0282/ for details, but basically this is commit leaves the string replacement to the logging function, instead of doing it in place in its parameters with the '%' operator. --- libmat/mat.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'libmat/mat.py') diff --git a/libmat/mat.py b/libmat/mat.py index df607a5..42357d6 100644 --- a/libmat/mat.py +++ b/libmat/mat.py @@ -119,7 +119,7 @@ def secure_remove(filename): try: # I want the file removed, even if it's read-only os.chmod(filename, 220) except OSError: - logging.error('Unable to add write rights to %s' % filename) + logging.error('Unable to add write rights to %s', filename) raise libmat.exceptions.UnableToWriteFile try: @@ -131,12 +131,12 @@ def secure_remove(filename): else: raise OSError except OSError: - logging.error('Unable to securely remove %s' % filename) + logging.error('Unable to securely remove %s', filename) try: os.remove(filename) except OSError: - logging.error('Unable to remove %s' % filename) + logging.error('Unable to remove %s', filename) raise libmat.exceptions.UnableToRemoveFile return True @@ -150,13 +150,13 @@ def create_class_file(name, backup, **kwargs): :param bool backup: shell the file be backuped? """ if not os.path.isfile(name): # check if the file exists - logging.error('%s is not a valid file' % name) + logging.error('%s is not a valid file', name) return None elif not os.access(name, os.R_OK): # check read permissions - logging.error('%s is is not readable' % name) + logging.error('%s is is not readable', name) return None elif not os.path.getsize(name): # check if the file is not empty (hachoir crash on empty files) - logging.error('%s is empty' % name) + logging.error('%s is empty', name) return None try: @@ -166,11 +166,11 @@ def create_class_file(name, backup, **kwargs): parser = hachoir_parser.createParser(filename) if not parser: - logging.info('Unable to parse %s with hachoir' % filename) + logging.info('Unable to parse %s with hachoir', filename) mime = mimetypes.guess_type(name)[0] if not mime: - logging.info('Unable to find mimetype of %s' % filename) + logging.info('Unable to find mimetype of %s', filename) return None if mime.startswith('application/vnd.oasis.opendocument'): @@ -183,7 +183,7 @@ def create_class_file(name, backup, **kwargs): try: stripper_class = strippers.STRIPPERS[mime] except KeyError: - logging.info('Don\'t have stripper for %s format' % mime) + logging.info('Don\'t have stripper for %s format', mime) return None return stripper_class(filename, parser, mime, backup, is_writable, **kwargs) -- cgit v1.3