Guess the extension for a file based on its MIME type. Return value is a string giving a filename extension, including the leading dot ('.'). The extension is not guaranteed to have been associated with any particular data stream, but would be mapped to the MIME typ
(self, type, strict=True)
| 219 | return extensions |
| 220 | |
| 221 | def guess_extension(self, type, strict=True): |
| 222 | """Guess the extension for a file based on its MIME type. |
| 223 | |
| 224 | Return value is a string giving a filename extension, |
| 225 | including the leading dot ('.'). The extension is not |
| 226 | guaranteed to have been associated with any particular data |
| 227 | stream, but would be mapped to the MIME type 'type' by |
| 228 | guess_type(). If no extension can be guessed for 'type', None |
| 229 | is returned. |
| 230 | |
| 231 | Optional 'strict' argument when false adds a bunch of commonly found, |
| 232 | but non-standard types. |
| 233 | """ |
| 234 | extensions = self.guess_all_extensions(type, strict) |
| 235 | if not extensions: |
| 236 | return None |
| 237 | return extensions[0] |
| 238 | |
| 239 | def read(self, filename, strict=True): |
| 240 | """ |