Make some POU libraries selected by default or not. This changes structure of features.libraries, please check and update your extensions if they use libraries
authorEdouard Tisserant
Mon, 06 Aug 2018 13:14:50 +0200
changeset 2244 42566291b9bc
parent 2243 02f03bd7639e
child 2245 fe3394697b02
Make some POU libraries selected by default or not. This changes structure of features.libraries, please check and update your extensions if they use libraries
ProjectController.py
features.py
--- a/ProjectController.py	Wed Jul 04 17:47:38 2018 +0300
+++ b/ProjectController.py	Mon Aug 06 13:14:50 2018 +0200
@@ -194,8 +194,9 @@
               <xsd:complexType>
               """+"\n".join(['<xsd:attribute name=' +
                              '"Enable_' + libname + '_Library" ' +
-                             'type="xsd:boolean" use="optional" default="false"/>'
-                             for libname, _lib in features.libraries])+"""
+                             'type="xsd:boolean" use="optional" default="' + 
+                                ('true' if default else 'false') + '"/>'
+                             for libname, _lib, default in features.libraries])+"""
               </xsd:complexType>
             </xsd:element>""") if len(features.libraries) > 0 else '') + """
           </xsd:sequence>
@@ -205,6 +206,7 @@
       </xsd:element>
     </xsd:schema>
     """
+    print XSD
     return XSD
 
 
@@ -270,7 +272,7 @@
     def LoadLibraries(self):
         self.Libraries = []
         TypeStack = []
-        for libname, clsname in features.libraries:
+        for libname, clsname, default in features.libraries:
             if self.BeremizRoot.Libraries is not None and getattr(self.BeremizRoot.Libraries, "Enable_"+libname+"_Library"):
                 Lib = GetClassImporter(clsname)()(self, libname, TypeStack)
                 TypeStack.append(Lib.GetTypes())
--- a/features.py	Wed Jul 04 17:47:38 2018 +0300
+++ b/features.py	Mon Aug 06 13:14:50 2018 +0200
@@ -9,10 +9,10 @@
 # See COPYING file for copyrights details.
 
 libraries = [
-    ('Native', 'NativeLib.NativeLibrary'),
-    ('Python', 'py_ext.PythonLibrary'),
-    ('Etherlab', 'etherlab.EthercatMaster.EtherlabLibrary'),
-    ('SVGUI', 'svgui.SVGUILibrary')]
+    ('Native', 'NativeLib.NativeLibrary', True),
+    ('Python', 'py_ext.PythonLibrary', True),
+    ('Etherlab', 'etherlab.EthercatMaster.EtherlabLibrary', False),
+    ('SVGUI', 'svgui.SVGUILibrary', False)]
 
 catalog = [
     ('canfestival', _('CANopen support'), _('Map located variables over CANopen'), 'canfestival.canfestival.RootClass'),