diff options
| author | jvoisin | 2013-10-27 23:01:20 +0000 |
|---|---|---|
| committer | jvoisin | 2013-10-27 23:01:20 +0000 |
| commit | 4c81e731a485d3ea84049ef6d568153c8b10e90b (patch) | |
| tree | 86ad43d7df67ed8d27cfbe7ff60dda1545784845 /MAT/office.py | |
| parent | 6f21743fdae533d7a94f64fb03d706fb342aff01 (diff) | |
Improves documentation
Diffstat (limited to 'MAT/office.py')
| -rw-r--r-- | MAT/office.py | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/MAT/office.py b/MAT/office.py index 583e0f9..91e49be 100644 --- a/MAT/office.py +++ b/MAT/office.py | |||
| @@ -1,5 +1,4 @@ | |||
| 1 | ''' | 1 | ''' Care about office's formats |
| 2 | Care about office's formats | ||
| 3 | ''' | 2 | ''' |
| 4 | 3 | ||
| 5 | import os | 4 | import os |
| @@ -23,14 +22,12 @@ import archive | |||
| 23 | 22 | ||
| 24 | 23 | ||
| 25 | class OpenDocumentStripper(archive.GenericArchiveStripper): | 24 | class OpenDocumentStripper(archive.GenericArchiveStripper): |
| 26 | ''' | 25 | ''' An open document file is a zip, with xml file into. |
| 27 | An open document file is a zip, with xml file into. | ||
| 28 | The one that interest us is meta.xml | 26 | The one that interest us is meta.xml |
| 29 | ''' | 27 | ''' |
| 30 | 28 | ||
| 31 | def get_meta(self): | 29 | def get_meta(self): |
| 32 | ''' | 30 | ''' Return a dict with all the meta of the file by |
| 33 | Return a dict with all the meta of the file by | ||
| 34 | trying to read the meta.xml file. | 31 | trying to read the meta.xml file. |
| 35 | ''' | 32 | ''' |
| 36 | zipin = zipfile.ZipFile(self.filename, 'r') | 33 | zipin = zipfile.ZipFile(self.filename, 'r') |
| @@ -103,8 +100,7 @@ class OpenDocumentStripper(archive.GenericArchiveStripper): | |||
| 103 | return True | 100 | return True |
| 104 | 101 | ||
| 105 | def is_clean(self): | 102 | def is_clean(self): |
| 106 | ''' | 103 | ''' Check if the file is clean from harmful metadatas |
| 107 | Check if the file is clean from harmful metadatas | ||
| 108 | ''' | 104 | ''' |
| 109 | zipin = zipfile.ZipFile(self.filename, 'r') | 105 | zipin = zipfile.ZipFile(self.filename, 'r') |
| 110 | try: | 106 | try: |
| @@ -120,8 +116,7 @@ class OpenDocumentStripper(archive.GenericArchiveStripper): | |||
| 120 | 116 | ||
| 121 | 117 | ||
| 122 | class PdfStripper(parser.GenericParser): | 118 | class PdfStripper(parser.GenericParser): |
| 123 | ''' | 119 | ''' Represent a PDF file |
| 124 | Represent a PDF file | ||
| 125 | ''' | 120 | ''' |
| 126 | def __init__(self, filename, parser, mime, backup, is_writable, **kwargs): | 121 | def __init__(self, filename, parser, mime, backup, is_writable, **kwargs): |
| 127 | super(PdfStripper, self).__init__(filename, parser, mime, backup, is_writable, **kwargs) | 122 | super(PdfStripper, self).__init__(filename, parser, mime, backup, is_writable, **kwargs) |
| @@ -137,8 +132,7 @@ class PdfStripper(parser.GenericParser): | |||
| 137 | 'producer', 'metadata']) | 132 | 'producer', 'metadata']) |
| 138 | 133 | ||
| 139 | def is_clean(self): | 134 | def is_clean(self): |
| 140 | ''' | 135 | ''' Check if the file is clean from harmful metadatas |
| 141 | Check if the file is clean from harmful metadatas | ||
| 142 | ''' | 136 | ''' |
| 143 | for key in self.meta_list: | 137 | for key in self.meta_list: |
| 144 | if self.document.get_property(key): | 138 | if self.document.get_property(key): |
| @@ -146,8 +140,7 @@ class PdfStripper(parser.GenericParser): | |||
| 146 | return True | 140 | return True |
| 147 | 141 | ||
| 148 | def remove_all(self): | 142 | def remove_all(self): |
| 149 | ''' | 143 | ''' Opening the PDF with poppler, then doing a render |
| 150 | Opening the PDF with poppler, then doing a render | ||
| 151 | on a cairo pdfsurface for each pages. | 144 | on a cairo pdfsurface for each pages. |
| 152 | 145 | ||
| 153 | http://cairographics.org/documentation/pycairo/2/ | 146 | http://cairographics.org/documentation/pycairo/2/ |
| @@ -195,8 +188,7 @@ pdfrw' % self.output) | |||
| 195 | return True | 188 | return True |
| 196 | 189 | ||
| 197 | def get_meta(self): | 190 | def get_meta(self): |
| 198 | ''' | 191 | ''' Return a dict with all the meta of the file |
| 199 | Return a dict with all the meta of the file | ||
| 200 | ''' | 192 | ''' |
| 201 | metadata = {} | 193 | metadata = {} |
| 202 | for key in self.meta_list: | 194 | for key in self.meta_list: |
| @@ -252,8 +244,7 @@ class OpenXmlStripper(archive.GenericArchiveStripper): | |||
| 252 | return True | 244 | return True |
| 253 | 245 | ||
| 254 | def is_clean(self): | 246 | def is_clean(self): |
| 255 | ''' | 247 | ''' Check if the file is clean from harmful metadatas |
| 256 | Check if the file is clean from harmful metadatas | ||
| 257 | ''' | 248 | ''' |
| 258 | zipin = zipfile.ZipFile(self.filename, 'r') | 249 | zipin = zipfile.ZipFile(self.filename, 'r') |
| 259 | for item in zipin.namelist(): | 250 | for item in zipin.namelist(): |
| @@ -265,8 +256,7 @@ class OpenXmlStripper(archive.GenericArchiveStripper): | |||
| 265 | return czf.is_clean() | 256 | return czf.is_clean() |
| 266 | 257 | ||
| 267 | def get_meta(self): | 258 | def get_meta(self): |
| 268 | ''' | 259 | ''' Return a dict with all the meta of the file |
| 269 | Return a dict with all the meta of the file | ||
| 270 | ''' | 260 | ''' |
| 271 | zipin = zipfile.ZipFile(self.filename, 'r') | 261 | zipin = zipfile.ZipFile(self.filename, 'r') |
| 272 | metadata = {} | 262 | metadata = {} |
