summaryrefslogtreecommitdiff
path: root/libmat/office.py
diff options
context:
space:
mode:
authorjvoisin2015-11-25 19:29:18 +0100
committerjvoisin2015-11-26 15:47:30 +0100
commit2212039d70ce5c4e97c3943bb82d4231c10e1260 (patch)
treeafd2aedcf6bb4c2a9fc82d6f3b2d0f7ad2d0fbb8 /libmat/office.py
parent9ea3c2cbc456bfa9a903eaa0ed6a42a34d12e1c2 (diff)
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.
Diffstat (limited to 'libmat/office.py')
-rw-r--r--libmat/office.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/libmat/office.py b/libmat/office.py
index 00b8f34..72f77c8 100644
--- a/libmat/office.py
+++ b/libmat/office.py
@@ -44,7 +44,7 @@ class OpenDocumentStripper(archive.TerminalZipStripper):
44 # method to get all attributes of a node 44 # method to get all attributes of a node
45 pass 45 pass
46 except KeyError: # no meta.xml file found 46 except KeyError: # no meta.xml file found
47 logging.debug('%s has no opendocument metadata' % self.filename) 47 logging.debug('%s has no opendocument metadata', self.filename)
48 zipin.close() 48 zipin.close()
49 return metadata 49 return metadata
50 50
@@ -153,7 +153,7 @@ class PdfStripper(parser.GenericParser):
153 surface = cairo.PDFSurface(output, 10, 10) 153 surface = cairo.PDFSurface(output, 10, 10)
154 context = cairo.Context(surface) # context draws on the surface 154 context = cairo.Context(surface) # context draws on the surface
155 155
156 logging.debug('PDF rendering of %s' % self.filename) 156 logging.debug('PDF rendering of %s', self.filename)
157 for pagenum in range(document.get_n_pages()): 157 for pagenum in range(document.get_n_pages()):
158 page = document.get_page(pagenum) 158 page = document.get_page(pagenum)
159 page_width, page_height = page.get_size() 159 page_width, page_height = page.get_size()
@@ -168,13 +168,13 @@ class PdfStripper(parser.GenericParser):
168 surface.finish() 168 surface.finish()
169 shutil.move(output, self.output) 169 shutil.move(output, self.output)
170 except: 170 except:
171 logging.error('Something went wrong when cleaning %s.' % self.filename) 171 logging.error('Something went wrong when cleaning %s.', self.filename)
172 return False 172 return False
173 173
174 try: 174 try:
175 import pdfrw # For now, poppler cannot write meta, so we must use pdfrw 175 import pdfrw # For now, poppler cannot write meta, so we must use pdfrw
176 176
177 logging.debug('Removing %s\'s superficial metadata' % self.filename) 177 logging.debug('Removing %s\'s superficial metadata', self.filename)
178 trailer = pdfrw.PdfReader(self.output) 178 trailer = pdfrw.PdfReader(self.output)
179 trailer.Info.Producer = None 179 trailer.Info.Producer = None
180 trailer.Info.Creator = None 180 trailer.Info.Creator = None
@@ -183,7 +183,7 @@ class PdfStripper(parser.GenericParser):
183 writer.write(self.output) 183 writer.write(self.output)
184 self.do_backup() 184 self.do_backup()
185 except: 185 except:
186 logging.error('Unable to remove all metadata from %s, please install pdfrw' % self.output) 186 logging.error('Unable to remove all metadata from %s, please install pdfrw', self.output)
187 return False 187 return False
188 return True 188 return True
189 189