>I thought i could use my beloved old TYPE and CREATOR, then I realized >that in MacOS X not every file has got them. >So i can check both the extension and the HFSFileType. > >Still i need a consistent way to express the file type. I need >something that given an HFSFileType returns the 'most used' extension, >or something that from an extension determines a file type. >Is there anything like that?
Don't think so, I looked for something similar myself and ended adding Type and Creator to every file that I recognize. Because I couldn't find a free extensive list of Type and Creator codes, I collected my own. Perhaps they are of use for anyone: # this type should get that extension type_ext_map = { \ '..CT' : 'ct', \ '8BIM' : 'psd', '8BPS' : 'psd', \ 'AB65' : 'p65', \ 'AGD3' : 'fh8', 'AGD4' : 'fh9', 'AGD5' : 'fh10', 'AGD6' : 'fhmx', \ 'ALB3' : 'pm3', 'ALB4' : 'pm4', 'ALB5' : 'pm5', 'ALB6' : 'pm6', \ 'APPL' : 'app', \ 'aust' : 'sea', \ 'BMP' : 'bmp', '.BMP' : 'bmp', 'BMP_' : 'bmp', 'BMPf' : 'bmp', \ 'CDIC' : 'dic', \ 'CDR6' : 'cdr', 'CDRW' : 'cdr', \ 'CDT' : 'cdt', '.CDT' : 'cdt', 'CDT_' : 'cdt', 'CDT6' : 'cdt', \ 'DWG' : 'dwg', \ 'DXF' : 'dxf', '.DXF' : 'dxf', 'DXF_' : 'dxf', \ 'EPSF' : 'eps', 'EPSP' : 'eps', \ 'FH10' : 'fh10', 'FH40' : 'fh4', 'FH50' : 'fh5', 'FH60' : 'fh6', 'FH70' : 'fh7', \ 'FH80' : 'fh8', 'FH90' : 'fh9', 'FHD3' : 'fh3', \ 'GIF' : 'gif', '.GIF' : 'gif', 'GIF_' : 'gif', 'GIFf' : 'gif', \ 'GZIP' : 'gz', \ 'ICO' : 'ico', \ 'inDd' : 'indd', \ 'JPEG' : 'jpg', \ 'MooV' : 'mov', \ 'MSWD' : 'doc', \ 'PCX' : 'pcx', \ 'PDF' : 'pdf', 'PDF ' : 'pdf', 'PDF_' : 'pdf', '.PDF' : 'pdf', \ 'PICT' : 'pict', \ 'PM3F' : 'pm3', 'PM4F' : 'pm4', 'PM5F' : 'pm5', \ 'PNG' : 'png', \ 'PPT3' : 'ppt', 'PPTV' : 'ppt', \ 'PUBF' : 'pm2', \ 'QTIF' : 'tif', \ 'RTF' : 'rtf', 'RTF ' : 'rtf', 'RTF_' : 'rtf', \ 'SLD8' : 'ppt', \ 'SWFL' : 'swf', \ 'SIT5' : 'sit', \ 'TGA' : 'tga', \ 'TIF' : 'tif', 'TIFF' : 'tif', \ 'TPIC' : 'tga', \ 'ttro' : 'txt', \ 'W6BN' : 'doc', 'W8BN' : 'doc', 'WDBN' : 'doc', \ 'WMF' : 'wmf', 'WMF ' : 'wmf', 'WMF_' : 'wmf', \ 'WP4' : 'wpd', 'WP5' : 'wpd', 'WP6' : 'wpd', 'WPD0' : 'wpd', \ 'WPRD' : 'prd', \ 'XDOC' : 'qxd', \ 'XLS8' : 'xls', \ 'ZIP' : 'zip', 'ZIP ' : 'zip', 'ZIP_' : 'zip' \ } # this extension should have that type ext_type_map = { \ 'anz' : 'TEXT', \ 'app' : 'APPL', \ 'bmp' : 'BMPf', \ 'cdr' : 'CDRW', \ 'css' : 'TEXT', \ 'dmg' : 'devi', \ 'doc' : 'WDBN', \ 'eps' : 'EPSF', \ 'fhmx' : 'AGD6', 'fh10' : 'AGD5', 'fh9' : 'AGD4', \ 'fh8' : 'AGD3', 'fh7' : 'AGD2', \ 'gif' : 'GIFf', \ 'gz' : 'GZIP', \ 'htm' : 'TEXT', 'html' : 'TEXT', \ 'idd' : 'InDd', 'indd' : 'InDd', \ 'jpg' : 'JPEG', 'jpeg' : 'JPEG', \ 'p65' : 'AB65', \ 'pdf' : 'PDF ', \ 'ps' : 'EPSF', \ 'psd' : '8BPS', \ 'qxd' : 'XDOC', \ 'rtf' : 'RTF ', \ 'sit' : 'SIT5', 'sea' : 'SIT5', \ 'tif' : 'TIFF', 'tiff' : 'TIFF', \ 'tga' : 'TPIC', \ 'txt' : 'TEXT' \ } # this extension should use that creator ext_creator_map = { \ 'anz' : 'ttxt', \ 'ai' : 'ART5', \ 'bmp' : '8BIM', \ 'css' : 'sfri', \ 'dmg' : 'ddsk', \ 'doc' : 'MSWD', \ 'fhmx' : 'FH11', 'fh10' : 'FH11', 'fh9' : 'FH11', \ 'fh8' : 'FH11', 'fh7' : 'FH11', 'fh6' : 'FH11', \ 'fh5' : 'FH11', \ 'gif' : '8BIM', \ 'html' : 'sfri', 'htm' : 'sfri', \ 'idd' : 'InDn', 'indd' : 'InDn', \ 'inc' : 'sfri', \ 'jpg' : '8BIM', \ 'pdf' : 'CARO', \ 'ppt' : 'PPT3', \ 'qxb' : 'XPR3', 'qxd' : 'XPR3', 'qxl' : 'XPR3', 'qxt' : 'XPR3', \ 'rtf' : 'MSWD', \ 'sit' : 'SITx', 'sea' : 'SITx', 'sitx' : 'SITx', \ 'tif' : '8BIM', \ 'tga' : '8BIM', \ 'xml' : 'MSIE', \ 'xsl' : 'XCEL', \ 'xtg' : 'XPR3', \ 'zip' : 'SITx' \ } # this type should use that creator type_creator_map = { \ '^FSF' : 'CARO', \ 'AGD2' : 'FH11', 'AGD3' : 'FH11', 'AGD4' : 'FH11', 'AGD5' : 'FH11', 'AGD6' : 'FH11', \ 'FDF' : 'CARO', 'FDF ' : 'CARO', 'FDF_' : 'CARO', \ 'GIFf' : '8BIM', \ 'JPEG' : '8BIM', \ 'PDF' : 'CARO', 'PDF ' : 'CARO', 'PDF_' : 'CARO', \ 'PICT' : '8BIM', \ 'TIFF' : '8BIM', \ 'WDBN' : 'MSWD' \ } # this creator should better be that creator_creator_map = { \ '' : '????', \ #'AGD1' : 'AGD6', 'AGD2' : 'AGD6', 'AGD3' : 'AGD6', 'AGD4' : 'AGD6', 'AGD5' : 'AGD6', \ 'ALD4' : 'AD65', 'ALD5' : 'AD65', 'ALD6' : 'AD65', \ 'ARTY' : 'ART5', 'ART2' : 'ART5', 'ART3' : 'ART5', \ 'ART4' : 'ART5', \ 'BNHQ' : 'SITx', \ 'FHA3' : 'FH11', 'FHA4' : 'FH11', 'FH04' : 'FH11', 'FH50' : 'FH11', 'FH60' : 'FH11', 'FH70' : 'FH11', 'FH80' : 'FH11', 'FH90' : 'FH11', \ 'GKON' : '8BIM', \ 'MOSS' : 'sfri', 'MOZZ' : 'sfri', 'MSIE' : 'sfri', \ 'MSWK' : 'MSWD', \ 'PACT' : 'SITx', \ 'R*ch' : 'ttxt', \ 'SIT!' : 'SITx' \ } # this creator means that application creator_name_map = { \ '' : 'Unknown', ' ' : 'Unknown', \ '????' : 'Unknown', \ '42ap' : 'GrandCentralPro', \ '8BIM' : 'Photoshop', \ 'ACAD' : 'AutoCAD', \ 'ALD4' : 'PageMaker 4', 'ALD5' : 'PageMaker 5', 'ALD6' : 'PageMaker 6.0', 'AD65' : 'PageMaker 6.5', \ 'ARTY' : 'Illustrator', 'ARTZ' : 'Illustrator', 'ART2' : 'Illustrator', 'ART3' : 'Illustrator', 'ART4' : 'Illustrator', 'ART5' : 'Illustrator', \ 'BNHQ' : 'BinHex', \ 'BOBO' : 'AppleWorks', \ 'CARO' : 'Acrobat', \ 'CDRW' : 'CorelDraw', \ 'drag' : 'MacOS X', \ 'EDIT' : 'TextEdit', \ 'ETF0' : 'etf-Jobticket', \ 'F#+A' : 'RagTime', \ 'FH70' : 'Freehand 7', 'FH80' : 'Freehand 8', 'FH90' : 'Freehand 9', 'FH10' : 'Freehand 10', 'FH11' : 'Freehand MX', \ 'GKON' : 'GraphicConverter', \ 'hscd' : 'Unknown (CD)', \ 'InDn' : 'InDesign', \ 'JVWR' : 'Preview', \ 'LMAN' : 'Unknown (Windows)', \ 'MOSS' : 'Netscape Navigator', \ 'MOZZ' : 'Mozilla', \ 'MPS ' : 'Cicero', \ 'MSIE' : 'Internet Explorer', \ 'MSWD' : 'MS Word', \ 'MSWK' : 'MS Works', \ 'PACT' : 'Compactor', \ 'PPT3' : 'PowerPoint', \ 'prvw' : 'Preview', \ 'R*ch' : 'BBEdit', \ 'RSED' : 'ResEdit', \ 'SIT!' : 'StuffIt Classic', \ 'SITx' : 'StuffIt (Expander)', \ 'sfri' : 'Safari', \ 'ttxt' : 'SimpleText', \ 'UNIX' : 'Unknown (UNIX)', \ 'vgrd' : 'Corel Draw SE', \ 'XCEL' : 'Excel', \ 'XPR3' : 'QuarkXPress' \ } # this type means that file type type_name_map = { \ '' : 'unknown file', ' ' : 'unknown file', \ '????' : 'unknown file', \ '42dl' : 'running Download', \ 'AGD3' : 'Freehand 8 Document', 'AGD4' : 'Freehand 9 Document', \ 'clpt' : 'Text-Clip', \ 'APPL' : 'Program', \ 'BINA' : 'Binary', \ 'EPSF' : 'EPS', \ 'EPSP' : 'EPS', \ 'etff' : 'Jobticket', \ 'FFIL' : 'Font Suitcase', \ 'InDd' : 'InDesign Document', \ 'LWFN' : 'PostScript Font', \ 'PDF ' : 'PDF', \ 'SIT5' : 'StuffIt Archive', 'SITD' : 'StuffIt Archive', \ 'TEXT' : 'Text File', \ 'WDBN' : 'Word Document', \ 'XDOC' : 'XPress Document' \ } Best regards, Henning Hraban Ramm Südkurier Medienhaus / MediaPro Support/Admin/Development Dept. _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig