Utilities/mimetypes.py

Fri, 23 May 2014 18:43:13 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 23 May 2014 18:43:13 +0200
branch
5_4_x
changeset 3606
f2f90775526f
parent 3567
d739e8de1b4f
permissions
-rw-r--r--

Added "application/x-desktop" to the text mimetypes.
(grafted from 646288f2fc190608892e908188a2a0cd22778a1b)

3567
d739e8de1b4f 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 -*-
d739e8de1b4f 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
d739e8de1b4f 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>
d739e8de1b4f 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 #
d739e8de1b4f 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
d739e8de1b4f 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 """
d739e8de1b4f 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.
d739e8de1b4f 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 """
d739e8de1b4f 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
d739e8de1b4f 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 import mimetypes
d739e8de1b4f 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
d739e8de1b4f 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 TextMimeTypes = [
d739e8de1b4f 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 "application/bookmarks.xbel",
d739e8de1b4f 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 "application/opensearchdescription+xml",
d739e8de1b4f 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/x-actionscript",
d739e8de1b4f 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/x-actionscript3",
d739e8de1b4f 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-awk",
d739e8de1b4f 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-sh",
d739e8de1b4f 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-shellscript",
d739e8de1b4f 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-shell-session",
d739e8de1b4f 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-dos-batch",
d739e8de1b4f 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-befunge",
d739e8de1b4f 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-brainfuck",
d739e8de1b4f 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-javascript+cheetah",
d739e8de1b4f 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-javascript+spitfire",
d739e8de1b4f 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-cheetah",
d739e8de1b4f 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-spitfire",
d739e8de1b4f 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/xml+cheetah",
d739e8de1b4f 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/xml+spitfire",
d739e8de1b4f 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/x-clojure",
d739e8de1b4f 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/x-coldfusion",
d739e8de1b4f 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-cython",
d739e8de1b4f 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-django-templating",
d739e8de1b4f 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-jinja",
d739e8de1b4f 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/xml-dtd",
d739e8de1b4f 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-ecl",
d739e8de1b4f 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/x-ruby-templating",
d739e8de1b4f 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-evoque",
d739e8de1b4f 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/xml+evoque",
d739e8de1b4f 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-fantom",
d739e8de1b4f 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/x-genshi",
d739e8de1b4f 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-kid",
d739e8de1b4f 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-text",
d739e8de1b4f 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-gettext",
d739e8de1b4f 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-troff",
d739e8de1b4f 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/xhtml+xml",
d739e8de1b4f 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-php",
d739e8de1b4f 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/x-httpd-php",
d739e8de1b4f 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-httpd-php3",
d739e8de1b4f 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-php4",
d739e8de1b4f 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-php5",
d739e8de1b4f 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-hybris",
d739e8de1b4f 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-javascript+django",
d739e8de1b4f 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-javascript+jinja",
d739e8de1b4f 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+ruby",
d739e8de1b4f 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+genshi",
d739e8de1b4f 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/javascript",
d739e8de1b4f 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",
d739e8de1b4f 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/x-javascript+php",
d739e8de1b4f 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+smarty",
d739e8de1b4f 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/json",
d739e8de1b4f 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-jsp",
d739e8de1b4f 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/x-julia",
d739e8de1b4f 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-httpd-lasso",
d739e8de1b4f 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-httpd-lasso[89]",
d739e8de1b4f 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-lasso8",
d739e8de1b4f 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-lasso9",
d739e8de1b4f 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-javascript+lasso",
d739e8de1b4f 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/xml+lasso",
d739e8de1b4f 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-lua",
d739e8de1b4f 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/x-javascript+mako",
d739e8de1b4f 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-mako",
d739e8de1b4f 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/xml+mako",
d739e8de1b4f 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-gooddata-maql",
d739e8de1b4f 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/x-mason",
d739e8de1b4f 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-moonscript",
d739e8de1b4f 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-javascript+myghty",
d739e8de1b4f 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-myghty",
d739e8de1b4f 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/xml+myghty",
d739e8de1b4f 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-newlisp",
d739e8de1b4f 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/x-openedge",
d739e8de1b4f 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-perl",
d739e8de1b4f 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/postscript",
d739e8de1b4f 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-pypylog",
d739e8de1b4f 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/x-python3",
d739e8de1b4f 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-python",
d739e8de1b4f 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-qml",
d739e8de1b4f 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-racket",
d739e8de1b4f 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-pygments-tokens",
d739e8de1b4f 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-ruby",
d739e8de1b4f 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-standardml",
d739e8de1b4f 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-scheme",
d739e8de1b4f 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-sh-session",
d739e8de1b4f 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-smarty",
d739e8de1b4f 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-ssp",
d739e8de1b4f 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-tcl",
d739e8de1b4f 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-csh",
d739e8de1b4f 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-urbiscript",
d739e8de1b4f 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/xml+velocity",
d739e8de1b4f 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/xquery",
d739e8de1b4f 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+django",
d739e8de1b4f 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/xml+jinja",
d739e8de1b4f 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+ruby",
d739e8de1b4f 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",
d739e8de1b4f 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/rss+xml",
d739e8de1b4f 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/atom+xml",
d739e8de1b4f 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/xml+php",
d739e8de1b4f 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/xml+smarty",
d739e8de1b4f 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/xsl+xml",
d739e8de1b4f 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/xslt+xml",
3606
f2f90775526f Added "application/x-desktop" to the text mimetypes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3567
diff changeset
111 "application/x-desktop",
3567
d739e8de1b4f 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
d739e8de1b4f 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
113 "image/svg+xml",
d739e8de1b4f 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 ]
d739e8de1b4f 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
d739e8de1b4f 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
d739e8de1b4f 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 def isTextFile(filename):
d739e8de1b4f 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 """
d739e8de1b4f 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 Function to test, if the given file is a text (i.e. editable) file.
d739e8de1b4f 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
d739e8de1b4f 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 @param filename name of the file to be checked (string)
d739e8de1b4f 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 @return flag indicating an editable file (boolean)
d739e8de1b4f 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 """
d739e8de1b4f 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 type_ = mimetypes.guess_type(filename)[0]
d739e8de1b4f 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 if (type_ is None or
d739e8de1b4f 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_.split("/")[0] == "text" or
d739e8de1b4f 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 type_ in TextMimeTypes):
d739e8de1b4f 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 return True
d739e8de1b4f 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 else:
d739e8de1b4f 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 False

eric ide

mercurial