Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 4 #------------------------------------------------------------------------------ 5 # Copyright (C) 2006-2008 University of Dundee. All rights reserved. 6 # 7 # 8 # This program is free software; you can redistribute it and/or modify 9 # it under the terms of the GNU General Public License as published by 10 # the Free Software Foundation; either version 2 of the License, or 11 # (at your option) any later version. 12 # This program is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License along 18 # with this program; if not, write to the Free Software Foundation, Inc., 19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 # 21 #---------------------------------------------------------------------- 22 23 ### 24 # 25 # Original file utilities 26 # This file supplies some utilities to deal with OriginalFile Objects. 27 # 28 # 29 # @author Jean-Marie Burel 30 # <a href="mailto:j.burel@dundee.ac.uk">j.burel@dundee.ac.uk</a> 31 # @author Donald MacDonald 32 # <a href="mailto:donald@lifesci.dundee.ac.uk">donald@lifesci.dundee.ac.uk</a> 33 # @version 3.0 34 # <small> 35 # (<b>Internal version:</b> $Revision: $Date: $) 36 # </small> 37 # @since 3.0-Beta4 38 #/ 39 import mimetypes; 40 41 importerMap = {'.dcm':'Dicom', 42 '.dicom':'Dicom', 43 '.pic':'BioRad', 44 '.ipl':'IPLab', 45 '.iplm':'IPLab', 46 '.dv':'Deltavision', 47 '.r3d':'Deltavision', 48 '.mrc':'MRC', 49 '.dm3':'Gatan', 50 '.ims':'Imaris', 51 '.raw':'OpenlabRaw', 52 '.ome':'OMEXML', 53 '.lif':'LIF', 54 '.sdt':'SDT', 55 '.sld':'Slidebook', 56 '.al3d':'Alicona', 57 '.mng':'MNG', 58 '.nrrd':'NNRD', 59 '.xv':'Khoros', 60 '.xys':'Visitech', 61 '.lim':'LIM', 62 '.xdce':'InCell', 63 '.ics':'ICS', 64 '.2':'PerkinElmer', 65 '.3':'PerkinElmer', 66 '.4':'PerkinElmer', 67 '.5':'PerkinElmer', 68 '.6':'PerkinElmer', 69 '.7':'PerkinElmer', 70 '.8':'PerkinElmer', 71 '.9':'PerkinElmer', 72 '.zvi':'ZeissZVI', 73 '.ipw':'IPW', 74 '.nef':'LegecyND2', 75 '.nd2':'ND2', 76 '.cxd':'PCI', 77 '.stk':'Metamorph', 78 '.lsm':'ZeissLSM', 79 '.seq':'SEQ', 80 '.gel':'Gel', 81 '.flex':'Flex', 82 '.svs':'SVS', 83 '.lei':'Leica', 84 '.oib':'Fluoview', 85 '.oif':'Fluoview', 86 '.ome.tif':'OMETiff', 87 '.liff':'Openlab'}; 88 89 formatMap = {'.avi':'AVI', 90 '.qt':'QT', 91 '.pic':'Pict', 92 '.eps':'EPS', 93 '.psd':'PSD', 94 '.jp2':'video/jpeg2000', 95 '.tif':'image/tiff', 96 '.tiff':'image/tiff'}; 97 98 UNKNOWN = 'type/unknown'; 99 KNOWNMIMETYPE = 'type/known'; 100 IMPORTER = 'application/importer'; 101103 if(filename==None): 104 return filename; 105 str = filename.split('.'); 106 if(len(str)<2): 107 return None; 108 return str[len(str)-1];109111 if(getExtension(filename)==None): 112 return (UNKNOWN, UNKNOWN); 113 if(getExtension(filename) in importerMap): 114 return (IMPORTER, importerMap[filename]); 115 if(getExtension(filename) in formatMap): 116 return (KNOWNMIMETYPE, formatMap[filename]); 117 if(mimetypes.guess_type(filename) != (None, None)): 118 return (KNOWNMIMETYPE, mimetypes.guess_type(filename)[0]); 119 else: 120 return (UNKNOWN, UNKNOWN);121
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Sep 23 15:04:57 2014 | http://epydoc.sourceforge.net |