[gen] Bugfixes.

This commit is contained in:
Gaetan Delannay 2012-12-18 22:49:26 +01:00
parent 70b18f597f
commit 446a2d9a16
3 changed files with 24 additions and 10 deletions

View file

@ -18,7 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,USA.
# ------------------------------------------------------------------------------
import os, os.path, re, time, sys, traceback, unicodedata, shutil
import os, os.path, re, time, sys, traceback, unicodedata, shutil, mimetypes
sequenceTypes = (list, tuple)
# ------------------------------------------------------------------------------
@ -532,4 +532,16 @@ class FileWrapper:
tool.log(CONVERSION_ERROR % (cmd, errorMessage), type='error')
return
return filePath
# ------------------------------------------------------------------------------
def getMimeType(fileName):
'''Tries to guess mime type from p_fileName.'''
res, encoding = mimetypes.guess_type(fileName)
if not res:
if fileName.endswith('.po'):
res = 'text/plain'
encoding = 'utf-8'
if not res: return ''
if not encoding: return res
return '%s;;charset=%s' % (res, encoding)
# ------------------------------------------------------------------------------