Utilities/MimeTypes.py

Sun, 30 Nov 2014 13:07:14 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 30 Nov 2014 13:07:14 +0100
branch
5_5_x
changeset 3952
6a7a407548d0
parent 3619
4643a9ef7dd6
child 4021
195a471c327b
permissions
-rw-r--r--

Prepared release 5.5.1.

3565
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de>
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing mimetype dependent functions.
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import mimetypes
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 TextMimeTypes = [
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 "application/bookmarks.xbel",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 "application/opensearchdescription+xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 "application/x-actionscript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 "application/x-actionscript3",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 "application/x-awk",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 "application/x-sh",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 "application/x-shellscript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 "application/x-shell-session",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 "application/x-dos-batch",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 "application/x-befunge",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 "application/x-brainfuck",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 "application/x-javascript+cheetah",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 "application/x-javascript+spitfire",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 "application/x-cheetah",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 "application/x-spitfire",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 "application/xml+cheetah",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 "application/xml+spitfire",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 "application/x-clojure",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 "application/x-coldfusion",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 "application/x-cython",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 "application/x-django-templating",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 "application/x-jinja",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 "application/xml-dtd",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 "application/x-ecl",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 "application/x-ruby-templating",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 "application/x-evoque",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 "application/xml+evoque",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 "application/x-fantom",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 "application/x-genshi",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 "application/x-kid",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 "application/x-genshi-text",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 "application/x-gettext",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 "application/x-troff",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 "application/xhtml+xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 "application/x-php",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 "application/x-httpd-php",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 "application/x-httpd-php3",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 "application/x-httpd-php4",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 "application/x-httpd-php5",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 "application/x-hybris",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 "application/x-javascript+django",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 "application/x-javascript+jinja",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 "application/x-javascript+ruby",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 "application/x-javascript+genshi",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 "application/javascript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 "application/x-javascript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 "application/x-javascript+php",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 "application/x-javascript+smarty",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 "application/json",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 "application/x-jsp",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 "application/x-julia",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 "application/x-httpd-lasso",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 "application/x-httpd-lasso[89]",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 "application/x-httpd-lasso8",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 "application/x-httpd-lasso9",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 "application/x-javascript+lasso",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 "application/xml+lasso",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 "application/x-lua",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 "application/x-javascript+mako",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 "application/x-mako",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 "application/xml+mako",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 "application/x-gooddata-maql",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 "application/x-mason",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 "application/x-moonscript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 "application/x-javascript+myghty",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 "application/x-myghty",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 "application/xml+myghty",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 "application/x-newlisp",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 "application/x-openedge",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 "application/x-perl",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 "application/postscript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 "application/x-pypylog",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 "application/x-python3",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 "application/x-python",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 "application/x-qml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 "application/x-racket",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 "application/x-pygments-tokens",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 "application/x-ruby",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 "application/x-standardml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 "application/x-scheme",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 "application/x-sh-session",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 "application/x-smarty",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 "application/x-ssp",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 "application/x-tcl",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 "application/x-csh",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 "application/x-urbiscript",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 "application/xml+velocity",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 "application/xquery",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 "application/xml+django",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 "application/xml+jinja",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 "application/xml+ruby",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 "application/xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 "application/rss+xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 "application/atom+xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 "application/xml+php",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 "application/xml+smarty",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 "application/xsl+xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 "application/xslt+xml",
3605
646288f2fc19 Added "application/x-desktop" to the text mimetypes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3565
diff changeset
113 "application/x-desktop",
3565
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 "image/svg+xml",
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 ]
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 def isTextFile(filename):
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 """
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 Function to test, if the given file is a text (i.e. editable) file.
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 @param filename name of the file to be checked (string)
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 @return flag indicating an editable file (boolean)
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 """
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 type_ = mimetypes.guess_type(filename)[0]
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 if (type_ is None or
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 type_.split("/")[0] == "text" or
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 type_ in TextMimeTypes):
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 return True
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 else:
8e1cd7721515 Added a utility function to handle mime types other than 'text' that are editable text files as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 return False

eric ide

mercurial