src/eric7/Utilities/MimeTypes.py

branch
eric7
changeset 10929
edfd452bb9be
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
equal deleted inserted replaced
10928:46651e194fbe 10929:edfd452bb9be
31 Preferences.getUI("LoadUnknownMimeTypeFiles") 31 Preferences.getUI("LoadUnknownMimeTypeFiles")
32 or any( 32 or any(
33 fnmatch.fnmatch(filename, pat) 33 fnmatch.fnmatch(filename, pat)
34 for pat in Preferences.getUI("TextFilePatterns") 34 for pat in Preferences.getUI("TextFilePatterns")
35 ) 35 )
36 or EricMessageBox.yesNo( 36 or (
37 None, 37 Preferences.getUI("TextMimeTypesAskUser")
38 QCoreApplication.translate("MimeTypes", "Open File"), 38 and EricMessageBox.yesNo(
39 QCoreApplication.translate( 39 None,
40 "MimeTypes", 40 QCoreApplication.translate("MimeTypes", "Open File"),
41 "<p>Is the file <b>{0}</b> a text file to be opened in eric?</p>" 41 QCoreApplication.translate(
42 "<p><b>Note:</b> You may suppress this question by adding a pattern" 42 "MimeTypes",
43 " to the list of known text files on the <b>MimeTypes</b>" 43 "<p>Is the file <b>{0}</b> a text file to be opened in eric?"
44 " configuration page.</p>", 44 "</p><p><b>Note:</b> You may suppress this question by adding"
45 ).format(filename), 45 " a pattern to the list of known text files on the"
46 " <b>MimeTypes</b> configuration page.</p>",
47 ).format(filename),
48 )
46 ) 49 )
47 ) 50 )
48 else: 51 else:
49 return ( 52 return (
50 mimetype.split("/")[0] == "text" 53 mimetype.split("/")[0] == "text"
51 or mimetype in Preferences.getUI("TextMimeTypes") 54 or mimetype in Preferences.getUI("TextMimeTypes")
52 or EricMessageBox.yesNo( 55 or (
53 None, 56 Preferences.getUI("TextMimeTypesAskUser")
54 QCoreApplication.translate("MimeTypes", "Open File"), 57 and EricMessageBox.yesNo(
55 QCoreApplication.translate( 58 None,
56 "MimeTypes", 59 QCoreApplication.translate("MimeTypes", "Open File"),
57 "<p>The file <b>{0}</b> has the mime type <b>{1}</b>. This type" 60 QCoreApplication.translate(
58 " is not recognized as being text to be opened in eric. Is this" 61 "MimeTypes",
59 " an editable text file?</p>" 62 "<p>The file <b>{0}</b> has the mime type <b>{1}</b>. This type"
60 "<p><b>Note:</b> You may suppress this question by adding an" 63 " is not recognized as being text to be opened in eric. Is this"
61 " entry to the list of known text file types on the" 64 " an editable text file?</p>"
62 " <b>MimeTypes</b> configuration page.</p>", 65 "<p><b>Note:</b> You may suppress this question by adding an"
63 ).format(filename, mimetype), 66 " entry to the list of known text file types on the"
67 " <b>MimeTypes</b> configuration page.</p>",
68 ).format(filename, mimetype),
69 )
64 ) 70 )
65 ) 71 )
66 72
67 73
68 def mimeType(filename): 74 def mimeType(filename):

eric ide

mercurial