PluginProjectKivy.py

changeset 41
1d6ea7d73189
parent 40
9fce5c54f543
child 43
e0ec8dc346a0
equal deleted inserted replaced
40:9fce5c54f543 41:1d6ea7d73189
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the Kivy project plug-in. 7 Module implementing the Kivy project plug-in.
8 """ 8 """
9
10 from __future__ import unicode_literals
11 9
12 import os 10 import os
13 import glob 11 import glob
14 import fnmatch 12 import fnmatch
15 13
24 # Start-of-Header 22 # Start-of-Header
25 name = "Kivy Project Plugin" 23 name = "Kivy Project Plugin"
26 author = "Detlev Offenbach <detlev@die-offenbachs.de>" 24 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
27 autoactivate = True 25 autoactivate = True
28 deactivateable = True 26 deactivateable = True
29 version = "2.0.3" 27 version = "3.0.0"
30 className = "ProjectKivyPlugin" 28 className = "ProjectKivyPlugin"
31 packageName = "ProjectKivy" 29 packageName = "ProjectKivy"
32 shortDescription = "Project support for Kivy projects." 30 shortDescription = "Project support for Kivy projects."
33 longDescription = \ 31 longDescription = (
34 """This plugin implements project support for Kivy projects.""" 32 """This plugin implements project support for Kivy projects."""
33 )
35 needsRestart = False 34 needsRestart = False
36 pyqtApi = 2 35 pyqtApi = 2
37 python2Compatible = True
38 # End-of-Header 36 # End-of-Header
39 37
40 error = "" 38 error = ""
41 39
42 40
45 Module function to return the API files made available by this plugin. 43 Module function to return the API files made available by this plugin.
46 44
47 @param language language to get API file for (string) 45 @param language language to get API file for (string)
48 @return list of API filenames (list of string) 46 @return list of API filenames (list of string)
49 """ 47 """
50 if language in ["Python2"]: 48 if language in ["Python3"]:
51 apisDir = \ 49 apisDir = os.path.join(os.path.dirname(__file__),
52 os.path.join(os.path.dirname(__file__), "ProjectKivy", "APIs") 50 "ProjectKivy", "APIs")
53 apis = glob.glob(os.path.join(apisDir, '*.api')) 51 return glob.glob(os.path.join(apisDir, '*.api'))
54 else: 52 else:
55 apis = [] 53 return []
56 return apis
57 54
58 55
59 class ProjectKivyPlugin(QObject): 56 class ProjectKivyPlugin(QObject):
60 """ 57 """
61 Class implementing the Kivy project plugin. 58 Class implementing the Kivy project plugin.
97 """ 94 """
98 Public method to activate this plugin. 95 Public method to activate this plugin.
99 96
100 @return tuple of None and activation status (boolean) 97 @return tuple of None and activation status (boolean)
101 """ 98 """
102 try: 99 self.__e5project.registerProjectType(
103 self.__e5project.registerProjectType( 100 "Kivy", self.tr("Kivy"), self.fileTypesCallback,
104 "Kivy", self.tr("Kivy"), self.fileTypesCallback, 101 lexerAssociationCallback=self.lexerAssociationCallback,
105 lexerAssociationCallback=self.lexerAssociationCallback, 102 progLanguages=["Python3"])
106 progLanguages=["Python2"]) 103
107 except TypeError: 104 from Project.ProjectBrowser import (
108 # for backward compatibility 105 SourcesBrowserFlag, FormsBrowserFlag, TranslationsBrowserFlag,
109 self.__e5project.registerProjectType( 106 OthersBrowserFlag
110 "Kivy", self.tr("Kivy"), self.fileTypesCallback, 107 )
111 lexerAssociationCallback=self.lexerAssociationCallback)
112
113 from Project.ProjectBrowser import SourcesBrowserFlag, \
114 FormsBrowserFlag, TranslationsBrowserFlag, OthersBrowserFlag
115 Preferences.setProjectBrowserFlagsDefault( 108 Preferences.setProjectBrowserFlagsDefault(
116 "Kivy", 109 "Kivy",
117 SourcesBrowserFlag | 110 SourcesBrowserFlag |
118 FormsBrowserFlag | 111 FormsBrowserFlag |
119 TranslationsBrowserFlag | 112 TranslationsBrowserFlag |
172 Public method get the filetype associations of the Kivy project type. 165 Public method get the filetype associations of the Kivy project type.
173 166
174 @return dictionary with file type associations 167 @return dictionary with file type associations
175 """ 168 """
176 if self.__e5project.getProjectType() == "Kivy": 169 if self.__e5project.getProjectType() == "Kivy":
177 fileTypes = { 170 return {
178 "*.kv": "SOURCES", 171 "*.kv": "SOURCES",
179 "*.kivy": "SOURCES", 172 "*.kivy": "SOURCES",
180 "*.py": "SOURCES", 173 "*.py": "SOURCES",
181 } 174 }
182 else: 175 else:
183 fileTypes = {} 176 return {}
184 return fileTypes
185 177
186 def lexerAssociationCallback(self, filename): 178 def lexerAssociationCallback(self, filename):
187 """ 179 """
188 Public method to get the lexer association of the Kivy project type for 180 Public method to get the lexer association of the Kivy project type for
189 a file. 181 a file.

eric ide

mercurial