PluginProjectPyramid.py

changeset 19
f4adfe6e51b0
parent 13
227a115ab2a1
child 21
e58828e9a847
equal deleted inserted replaced
18:c27d4435675a 19:f4adfe6e51b0
40 40
41 error = "" 41 error = ""
42 42
43 pyramidPluginObject = None 43 pyramidPluginObject = None
44 44
45
45 def createPyramidPage(configDlg): 46 def createPyramidPage(configDlg):
46 """ 47 """
47 Module function to create the Pyramid configuration page. 48 Module function to create the Pyramid configuration page.
48 49
49 @return reference to the configuration page 50 @return reference to the configuration page
51 global pyramidPluginObject 52 global pyramidPluginObject
52 from ProjectPyramid.ConfigurationPage.PyramidPage import PyramidPage 53 from ProjectPyramid.ConfigurationPage.PyramidPage import PyramidPage
53 page = PyramidPage(pyramidPluginObject) 54 page = PyramidPage(pyramidPluginObject)
54 return page 55 return page
55 56
57
56 def getConfigData(): 58 def getConfigData():
57 """ 59 """
58 Module function returning data as required by the configuration dialog. 60 Module function returning data as required by the configuration dialog.
59 61
60 @return dictionary containing the relevant data 62 @return dictionary containing the relevant data
61 """ 63 """
62 if e5App().getObject("UserInterface").versionIsNewer('5.0.99', '20120101'): 64 if e5App().getObject("UserInterface").versionIsNewer('5.0.99', '20120101'):
63 return { 65 return {
64 "pyramidPage" : \ 66 "pyramidPage": \
65 [QCoreApplication.translate("ProjectPyramidPlugin", "Pyramid"), 67 [QCoreApplication.translate("ProjectPyramidPlugin", "Pyramid"),
66 os.path.join("ProjectPyramid", "icons", 68 os.path.join("ProjectPyramid", "icons",
67 "pyramid.png"), 69 "pyramid.png"),
68 createPyramidPage, None, None], 70 createPyramidPage, None, None],
69 } 71 }
70 else: 72 else:
71 return {} 73 return {}
74
72 75
73 def apiFiles(language): 76 def apiFiles(language):
74 """ 77 """
75 Module function to return the API files made available by this plugin. 78 Module function to return the API files made available by this plugin.
76 79
82 apis = glob.glob(os.path.join(apisDir, '*.api')) 85 apis = glob.glob(os.path.join(apisDir, '*.api'))
83 else: 86 else:
84 apis = [] 87 apis = []
85 return apis 88 return apis
86 89
90
87 def prepareUninstall(): 91 def prepareUninstall():
88 """ 92 """
89 Module function to prepare for an uninstallation. 93 Module function to prepare for an uninstallation.
90 """ 94 """
91 pyramid = ProjectPyramidPlugin(None) 95 pyramid = ProjectPyramidPlugin(None)
95 class ProjectPyramidPlugin(QObject): 99 class ProjectPyramidPlugin(QObject):
96 """ 100 """
97 Class implementing the Pyramid project plugin. 101 Class implementing the Pyramid project plugin.
98 """ 102 """
99 lexerAssociations = { 103 lexerAssociations = {
100 "*.mako": "Pygments|HTML+Mako", 104 "*.mako": "Pygments|HTML+Mako",
101 "*.pt": "Pygments|HTML+Genshi", 105 "*.pt": "Pygments|HTML+Genshi",
102 "*.txt": "Pygments|Genshi", 106 "*.txt": "Pygments|Genshi",
103 "*.html": "Pygments|HTML+Genshi", 107 "*.html": "Pygments|HTML+Genshi",
104 "*.htm": "Pygments|HTML+Genshi", 108 "*.htm": "Pygments|HTML+Genshi",
105 } 109 }
106 110
107 def __init__(self, ui): 111 def __init__(self, ui):
108 """ 112 """
109 Constructor 113 Constructor
113 QObject.__init__(self, ui) 117 QObject.__init__(self, ui)
114 self.__ui = ui 118 self.__ui = ui
115 self.__initialize() 119 self.__initialize()
116 120
117 self.__defaults = { 121 self.__defaults = {
118 "VirtualEnvironmentPy2" : "", 122 "VirtualEnvironmentPy2": "",
119 "VirtualEnvironmentPy3" : "", 123 "VirtualEnvironmentPy3": "",
120 "Python2ConsoleType": "python", 124 "Python2ConsoleType": "python",
121 "Python3ConsoleType": "python", 125 "Python3ConsoleType": "python",
122 "PyramidDocUrl": "http://docs.pylonsproject.org/en/latest/docs/pyramid.html", 126 "PyramidDocUrl": "http://docs.pylonsproject.org/en/latest/docs/pyramid.html",
123 } 127 }
124 if isWindowsPlatform(): 128 if isWindowsPlatform():
125 self.__defaults["ConsoleCommandNoClose"] = "cmd.exe /k" 129 self.__defaults["ConsoleCommandNoClose"] = "cmd.exe /k"
126 self.__defaults["ConsoleCommand"] = "cmd.exe /c" 130 self.__defaults["ConsoleCommand"] = "cmd.exe /c"
127 elif isMacPlatform(): 131 elif isMacPlatform():
178 self.__object.initActions() 182 self.__object.initActions()
179 e5App().registerPluginObject("ProjectPyramid", self.__object) 183 e5App().registerPluginObject("ProjectPyramid", self.__object)
180 184
181 self.__mainMenu = self.__object.initMenu() 185 self.__mainMenu = self.__object.initMenu()
182 186
183 self.__e5project.registerProjectType("Pyramid", self.trUtf8("Pyramid"), 187 self.__e5project.registerProjectType("Pyramid", self.trUtf8("Pyramid"),
184 self.fileTypesCallback, 188 self.fileTypesCallback,
185 lexerAssociationCallback = self.lexerAssociationCallback, 189 lexerAssociationCallback=self.lexerAssociationCallback,
186 binaryTranslationsCallback = self.binaryTranslationsCallback) 190 binaryTranslationsCallback=self.binaryTranslationsCallback)
187 Preferences.setProjectBrowserFlagsDefault("Pyramid", 191 Preferences.setProjectBrowserFlagsDefault("Pyramid",
188 SourcesBrowserFlag | \ 192 SourcesBrowserFlag | \
189 FormsBrowserFlag | \ 193 FormsBrowserFlag | \
190 TranslationsBrowserFlag | \ 194 TranslationsBrowserFlag | \
191 OthersBrowserFlag, 195 OthersBrowserFlag,
192 ) 196 )
277 281
278 @return dictionary with file type associations 282 @return dictionary with file type associations
279 """ 283 """
280 if self.__e5project.getProjectType() == "Pyramid": 284 if self.__e5project.getProjectType() == "Pyramid":
281 fileTypes = { 285 fileTypes = {
282 "*.mako": "FORMS", 286 "*.mako": "FORMS",
283 "*.mak": "FORMS", 287 "*.mak": "FORMS",
284 "*.pt": "FORMS", 288 "*.pt": "FORMS",
285 "*.html": "FORMS", 289 "*.html": "FORMS",
286 "*.htm": "FORMS", 290 "*.htm": "FORMS",
287 "*.js": "SOURCES", 291 "*.js": "SOURCES",
288 "*.pot": "TRANSLATIONS", 292 "*.pot": "TRANSLATIONS",
289 "*.po": "TRANSLATIONS", 293 "*.po": "TRANSLATIONS",
290 "*.mo": "TRANSLATIONS", 294 "*.mo": "TRANSLATIONS",
291 } 295 }
292 else: 296 else:
293 fileTypes = {} 297 fileTypes = {}
294 return fileTypes 298 return fileTypes
295 299

eric ide

mercurial