diff options
| author | jvoisin | 2013-01-07 22:37:54 +0100 |
|---|---|---|
| committer | jvoisin | 2013-01-07 22:37:54 +0100 |
| commit | 5027bba6c2c1c7546cfc0eb953de38181b7e4e7b (patch) | |
| tree | 094928d07c06070c59fa10132fb67a07386a6405 | |
| parent | 27189a6f322f720803759daf2061b503e0148963 (diff) | |
Refactor the get_sharedir function, and move datas to a proper data folder
| -rw-r--r-- | MAT/FORMATS | 43 | ||||
| -rw-r--r-- | MAT/mat.py | 26 | ||||
| -rw-r--r-- | data/FORMATS (renamed from FORMATS) | 0 | ||||
| -rw-r--r-- | data/mat.png (renamed from mat.png) | bin | 31340 -> 31340 bytes | |||
| -rwxr-xr-x | mat | 2 | ||||
| -rwxr-xr-x | mat-gui | 4 | ||||
| -rwxr-xr-x | setup.py | 4 |
7 files changed, 52 insertions, 27 deletions
diff --git a/MAT/FORMATS b/MAT/FORMATS index c497524..3f0751c 100644 --- a/MAT/FORMATS +++ b/MAT/FORMATS | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | <format> | 2 | <format> |
| 3 | <name>Portable Network Graphics</name> | 3 | <name>Portable Network Graphics</name> |
| 4 | <extension>.png</extension> | 4 | <extension>.png</extension> |
| 5 | <mimetype>image/png</mimetype> | ||
| 5 | <support>full</support> | 6 | <support>full</support> |
| 6 | <metadata>textual metadata + date</metadata> | 7 | <metadata>textual metadata + date</metadata> |
| 7 | <method>removal of harmful fields is done with hachoir</method> | 8 | <method>removal of harmful fields is done with hachoir</method> |
| @@ -10,14 +11,19 @@ | |||
| 10 | <format> | 11 | <format> |
| 11 | <name>Jpeg</name> | 12 | <name>Jpeg</name> |
| 12 | <extension>.jpeg, .jpg</extension> | 13 | <extension>.jpeg, .jpg</extension> |
| 13 | <support>full</support> | 14 | <mimetype>image/jpeg</mimetype> |
| 15 | <support>partial</support> | ||
| 14 | <metadata>comment + exif/photoshop/adobe</metadata> | 16 | <metadata>comment + exif/photoshop/adobe</metadata> |
| 15 | <method>removal of harmful fields is done with hachoir</method> | 17 | <method>removal of harmful fields is done with hachoir</method> |
| 18 | <remaining>Canon Raw tags : | ||
| 19 | http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/CanonRaw.html | ||
| 20 | </remaining> | ||
| 16 | </format> | 21 | </format> |
| 17 | 22 | ||
| 18 | <format> | 23 | <format> |
| 19 | <name>Open Document</name> | 24 | <name>Open Document</name> |
| 20 | <extension>.odt, .odx, .ods, ...</extension> | 25 | <extension>.odt, .odx, .ods, ...</extension> |
| 26 | <mimetype>application/opendocument</mimetype> | ||
| 21 | <support>full</support> | 27 | <support>full</support> |
| 22 | <metadata>a meta.xml file</metadata> | 28 | <metadata>a meta.xml file</metadata> |
| 23 | <method>removal of the meta.xml file</method> | 29 | <method>removal of the meta.xml file</method> |
| @@ -26,6 +32,7 @@ | |||
| 26 | <format> | 32 | <format> |
| 27 | <name>Office Openxml</name> | 33 | <name>Office Openxml</name> |
| 28 | <extension>.docx, .pptx, .xlsx, ...</extension> | 34 | <extension>.docx, .pptx, .xlsx, ...</extension> |
| 35 | <mimetype>application/officeopenxml</mimetype> | ||
| 29 | <support>full</support> | 36 | <support>full</support> |
| 30 | <metadata>a docProps folder containings xml metadata files</metadata> | 37 | <metadata>a docProps folder containings xml metadata files</metadata> |
| 31 | <method>removal of the docProps folder</method> | 38 | <method>removal of the docProps folder</method> |
| @@ -34,18 +41,21 @@ | |||
| 34 | <format> | 41 | <format> |
| 35 | <name>Portable Document Fileformat</name> | 42 | <name>Portable Document Fileformat</name> |
| 36 | <extension>.pdf</extension> | 43 | <extension>.pdf</extension> |
| 44 | <mimetype>application/pdf</mimetype> | ||
| 37 | <support>full</support> | 45 | <support>full</support> |
| 38 | <metadata>a lot</metadata> | 46 | <metadata>a lot</metadata> |
| 39 | <method>rendering of the pdf file on a cairo surface with the help of | 47 | <method> rendering of the PDF file on a cairo surface with the help of |
| 40 | poppler in order to remove all the internal metadata, | 48 | poppler in order to remove all the internal metadata. |
| 41 | then removal of the remaining metadata fields of the pdf itself with | 49 | For now, cairo create some metadata. |
| 42 | pdfrw (the next version of python-cairo will support metadata, | 50 | They can be remove if you install either exiftool, or python-pdfrw. |
| 43 | so we should get rid of pdfrw)</method> | 51 | The next version of python-cairo will support PDF metadata. |
| 52 | </method> | ||
| 44 | </format> | 53 | </format> |
| 45 | 54 | ||
| 46 | <format> | 55 | <format> |
| 47 | <name>Tape ARchive</name> | 56 | <name>Tape ARchive</name> |
| 48 | <extension>.tar, .tar.bz2, .tar.gz</extension> | 57 | <extension>.tar, .tar.bz2, .tar.gz</extension> |
| 58 | <mimetype>application/x-tar, application/x-gzip, application/x-bzip2</mimetype> | ||
| 49 | <support>full</support> | 59 | <support>full</support> |
| 50 | <metadata>metadata from the file itself, metadata from the file contained | 60 | <metadata>metadata from the file itself, metadata from the file contained |
| 51 | into the archive, and metadata added by tar to the file at then | 61 | into the archive, and metadata added by tar to the file at then |
| @@ -58,11 +68,11 @@ | |||
| 58 | <format> | 68 | <format> |
| 59 | <name>Zip</name> | 69 | <name>Zip</name> |
| 60 | <extension>.zip</extension> | 70 | <extension>.zip</extension> |
| 61 | <support>.partial</support> | 71 | <mimetype>application/zip</mimetype> |
| 72 | <support>partial</support> | ||
| 62 | <metadata>metadata from the file itself, metadata from the file contained | 73 | <metadata>metadata from the file itself, metadata from the file contained |
| 63 | into the archive, and metadata added by zip to the file when added to | 74 | into the archive, and metadata added by zip to the file when added to |
| 64 | the archive. | 75 | the archive.</metadata> |
| 65 | </metadata> | ||
| 66 | <method>extraction of each file, treatement of the file, add treated file | 76 | <method>extraction of each file, treatement of the file, add treated file |
| 67 | to a new archive. When the new archive is complete, remove all his metadata</method> | 77 | to a new archive. When the new archive is complete, remove all his metadata</method> |
| 68 | <remaining>metadata added by zip itself to internal files</remaining> | 78 | <remaining>metadata added by zip itself to internal files</remaining> |
| @@ -70,7 +80,8 @@ | |||
| 70 | 80 | ||
| 71 | <format> | 81 | <format> |
| 72 | <name>MPEG Audio</name> | 82 | <name>MPEG Audio</name> |
| 73 | <extension>.mp3, .mp2, .mp1</extension> | 83 | <extension>.mp3, .mp2, .mp1, .mpa</extension> |
| 84 | <mimetype>audio/mpeg</mimetype> | ||
| 74 | <support>full</support> | 85 | <support>full</support> |
| 75 | <metadata>id3</metadata> | 86 | <metadata>id3</metadata> |
| 76 | <method>removal of harmful fields is done with hachoir</method> | 87 | <method>removal of harmful fields is done with hachoir</method> |
| @@ -79,6 +90,7 @@ | |||
| 79 | <format> | 90 | <format> |
| 80 | <name>Ogg Vorbis</name> | 91 | <name>Ogg Vorbis</name> |
| 81 | <extension>.ogg</extension> | 92 | <extension>.ogg</extension> |
| 93 | <mimetype>audio/vorbis</mimetype> | ||
| 82 | <support>full</support> | 94 | <support>full</support> |
| 83 | <metadata>Vorbis</metadata> | 95 | <metadata>Vorbis</metadata> |
| 84 | <method>removal of harmful fields is done with mutagen</method> | 96 | <method>removal of harmful fields is done with mutagen</method> |
| @@ -87,8 +99,19 @@ | |||
| 87 | <format> | 99 | <format> |
| 88 | <name>Free Lossless Audio Codec</name> | 100 | <name>Free Lossless Audio Codec</name> |
| 89 | <extension>.flac</extension> | 101 | <extension>.flac</extension> |
| 102 | <mimetype>audio/x-flac</mimetype> | ||
| 90 | <support>full</support> | 103 | <support>full</support> |
| 91 | <metadata>Flac, Vorbis</metadata> | 104 | <metadata>Flac, Vorbis</metadata> |
| 92 | <method>removal of harmful fields is done with mutagen</method> | 105 | <method>removal of harmful fields is done with mutagen</method> |
| 93 | </format> | 106 | </format> |
| 107 | |||
| 108 | <format> | ||
| 109 | <name>Torrent</name> | ||
| 110 | <extension>.torrent</extension> | ||
| 111 | <mimetype>application/torrent</mimetype> | ||
| 112 | <support>full</support> | ||
| 113 | <metadata>torrent</metadata> | ||
| 114 | <method>remove all the compromizing metadata with a heavily tuned version | ||
| 115 | of the bencode lib by Petru Paled</method> | ||
| 116 | </format> | ||
| 94 | </xml> | 117 | </xml> |
| @@ -30,19 +30,21 @@ LOGGING_LEVEL = logging.DEBUG | |||
| 30 | 30 | ||
| 31 | logging.basicConfig(filename=fname, level=LOGGING_LEVEL) | 31 | logging.basicConfig(filename=fname, level=LOGGING_LEVEL) |
| 32 | 32 | ||
| 33 | def get_logo(): | ||
| 34 | if os.path.isfile('./data/mat.png'): | ||
| 35 | return './data/mat.png' | ||
| 36 | elif os.path.isfile('/usr/share/pixmaps/mat.png'): | ||
| 37 | return '/usr/share/pixmaps/mat.png' | ||
| 38 | elif os.path.isfile('/usr/local/share/pixmaps/mat.png'): | ||
| 39 | return '/usr/local/share/pixmaps/mat.png' | ||
| 33 | 40 | ||
| 34 | def get_sharedir(filename): | 41 | def get_formats(): |
| 35 | ''' | 42 | if os.path.isfile('./data/FORMATS'): |
| 36 | An ugly hack to find various files | 43 | return './data/FORMATS' |
| 37 | ''' | 44 | elif os.path.isfile('/usr/share/mat/FORMATS'): |
| 38 | if os.path.isfile(filename): | 45 | return '/usr/share/mat/FORMATS' |
| 39 | return filename | 46 | elif os.path.isfile('/usr/local/share/mat/FORMATS'): |
| 40 | elif os.path.exists(os.path.join('/usr/local/share/mat/', filename)): | 47 | return '/usr/local/share/mat/FORMATS' |
| 41 | return os.path.join('/usr/local/share/mat/', filename) | ||
| 42 | elif os.path.exists(os.path.join('/usr/share/mat/', filename)): | ||
| 43 | return os.path.join('/usr/share/mat', filename) | ||
| 44 | elif os.path.exists(os.path.join('/usr/local/share/pixmaps/', filename)): | ||
| 45 | return os.path.join('/usr/local/share/pixmaps/', filename) | ||
| 46 | 48 | ||
| 47 | 49 | ||
| 48 | class XMLParser(xml.sax.handler.ContentHandler): | 50 | class XMLParser(xml.sax.handler.ContentHandler): |
| Binary files differ | |||
| @@ -104,7 +104,7 @@ def list_supported(): | |||
| 104 | handler = mat.XMLParser() | 104 | handler = mat.XMLParser() |
| 105 | parser = xml.sax.make_parser() | 105 | parser = xml.sax.make_parser() |
| 106 | parser.setContentHandler(handler) | 106 | parser.setContentHandler(handler) |
| 107 | path = mat.get_sharedir('FORMATS') | 107 | path = mat.get_formats() |
| 108 | with open(path, 'r') as xmlfile: | 108 | with open(path, 'r') as xmlfile: |
| 109 | parser.parse(xmlfile) | 109 | parser.parse(xmlfile) |
| 110 | 110 | ||
| @@ -53,7 +53,7 @@ class GUI: | |||
| 53 | self.window.set_title('Metadata Anonymisation Toolkit') | 53 | self.window.set_title('Metadata Anonymisation Toolkit') |
| 54 | self.window.connect('destroy', gtk.main_quit) | 54 | self.window.connect('destroy', gtk.main_quit) |
| 55 | self.window.set_default_size(800, 600) | 55 | self.window.set_default_size(800, 600) |
| 56 | self.logo = mat.get_sharedir('mat.png') | 56 | self.logo = mat.get_logo() |
| 57 | icon = gtk.gdk.pixbuf_new_from_file_at_size(self.logo, 50, 50) | 57 | icon = gtk.gdk.pixbuf_new_from_file_at_size(self.logo, 50, 50) |
| 58 | self.window.set_icon(icon) | 58 | self.window.set_icon(icon) |
| 59 | 59 | ||
| @@ -405,7 +405,7 @@ class GUI: | |||
| 405 | handler = mat.XMLParser() | 405 | handler = mat.XMLParser() |
| 406 | parser = xml.sax.make_parser() | 406 | parser = xml.sax.make_parser() |
| 407 | parser.setContentHandler(handler) | 407 | parser.setContentHandler(handler) |
| 408 | path = mat.get_sharedir('FORMATS') | 408 | path = mat.get_formats() |
| 409 | with open(path, 'r') as xmlfile: | 409 | with open(path, 'r') as xmlfile: |
| 410 | parser.parse(xmlfile) | 410 | parser.parse(xmlfile) |
| 411 | 411 | ||
| @@ -27,8 +27,8 @@ setup( | |||
| 27 | scripts = ['mat', 'mat-gui'], | 27 | scripts = ['mat', 'mat-gui'], |
| 28 | data_files = [ | 28 | data_files = [ |
| 29 | ( 'share/applications', ['mat.desktop'] ), | 29 | ( 'share/applications', ['mat.desktop'] ), |
| 30 | ( 'share/mat', ['FORMATS'] ), | 30 | ( 'share/mat', ['data/FORMATS'] ), |
| 31 | ( 'share/pixmaps', ['mat.png'] ), | 31 | ( 'share/pixmaps', ['data/mat.png'] ), |
| 32 | ( 'share/doc/mat', ['README', 'TODO'] ), | 32 | ( 'share/doc/mat', ['README', 'TODO'] ), |
| 33 | ( 'share/man/man1', ['mat.1', 'mat-gui.1'] ), | 33 | ( 'share/man/man1', ['mat.1', 'mat-gui.1'] ), |
| 34 | ], | 34 | ], |
