diff options
Diffstat (limited to 'MAT')
| -rw-r--r-- | MAT/mat.py | 19 |
1 files changed, 18 insertions, 1 deletions
| @@ -13,7 +13,6 @@ import xml.sax | |||
| 13 | import hachoir_core.cmd_line | 13 | import hachoir_core.cmd_line |
| 14 | import hachoir_parser | 14 | import hachoir_parser |
| 15 | 15 | ||
| 16 | |||
| 17 | __version__ = '0.4' | 16 | __version__ = '0.4' |
| 18 | __author__ = 'jvoisin' | 17 | __author__ = 'jvoisin' |
| 19 | 18 | ||
| @@ -47,6 +46,24 @@ def get_datadir(): | |||
| 47 | elif os.path.isdir('/usr/local/share/mat/'): | 46 | elif os.path.isdir('/usr/local/share/mat/'): |
| 48 | return '/usr/local/share/mat/' | 47 | return '/usr/local/share/mat/' |
| 49 | 48 | ||
| 49 | def list_supported_formats(): | ||
| 50 | ''' | ||
| 51 | Return a list of all localy supported fileformat | ||
| 52 | ''' | ||
| 53 | handler = XMLParser() | ||
| 54 | parser = xml.sax.make_parser() | ||
| 55 | parser.setContentHandler(handler) | ||
| 56 | path = os.path.join(get_datadir(), 'FORMATS') | ||
| 57 | with open(path, 'r') as xmlfile: | ||
| 58 | parser.parse(xmlfile) | ||
| 59 | |||
| 60 | localy_supported = [] | ||
| 61 | for item in handler.list: | ||
| 62 | if strippers.STRIPPERS.has_key(item['mimetype'].split(',')[0]): | ||
| 63 | localy_supported.append(item) | ||
| 64 | |||
| 65 | return localy_supported | ||
| 66 | |||
| 50 | class XMLParser(xml.sax.handler.ContentHandler): | 67 | class XMLParser(xml.sax.handler.ContentHandler): |
| 51 | ''' | 68 | ''' |
| 52 | Parse the supported format xml, and return a corresponding | 69 | Parse the supported format xml, and return a corresponding |
