No subject


Thu Jun 7 16:37:16 CEST 2018


Patch OK to commit?

	Jan

-- 
Jan-Oliver Wagner               http://intevation.de/~jan/

Intevation GmbH                      http://intevation.de/
FreeGIS                                http://freegis.org/

--r5Pyd7+fXNt84Ff3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ext_reg.patch"

Index: Extensions/gns2shp/__init__.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/gns2shp/__init__.py,v
retrieving revision 1.2
diff -u -3 -p -r1.2 __init__.py
--- Extensions/gns2shp/__init__.py	16 Nov 2004 21:15:49 -0000	1.2
+++ Extensions/gns2shp/__init__.py	24 Feb 2005 22:33:19 -0000
@@ -1,17 +1,19 @@
-# Copyright (c) 2003, 2004 by Intevation GmbH
+# Copyright (c) 2003-2005 by Intevation GmbH
 # Authors:
-# Jan-Oliver Wagner <jan at intevation.de> (2003, 2004)
+# Jan-Oliver Wagner <jan at intevation.de> (2003-2005)
 #
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with Thuban for details.
 
-# import the actual module
-import gns2shp
-
 # perform the registration of the extension
 from Thuban import _
 from Thuban.UI.extensionregistry import ExtensionDesc, ext_registry
 
+def init():
+    """Initialize gns2shp extension module."""
+    import gns2shp
+    return None
+
 ext_registry.add(ExtensionDesc(
     name = 'gns2shp',
     version = '1.0.0',
@@ -19,4 +21,5 @@ ext_registry.add(ExtensionDesc(
     copyright = '2003, 2004 Intevation GmbH',
     desc = _("Converts GNS (Geographical Name Service\n" \
              "of NIMA) to Shapefile format and\n" \
-             "displays the data.")))
+             "displays the data."),
+    init_callback = init))
Index: Thuban/UI/application.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/application.py,v
retrieving revision 1.38
diff -u -3 -p -r1.38 application.py
--- Thuban/UI/application.py	13 Dec 2004 11:52:34 -0000	1.38
+++ Thuban/UI/application.py	24 Feb 2005 22:33:19 -0000
@@ -30,6 +30,8 @@ from Thuban.Model.messages import MAPS_C
 from Thuban.Model.layer import RasterLayer
 import Thuban.Model.resource
 
+from extensionregistry import ext_registry
+
 import view
 import tree
 import mainwindow
@@ -71,6 +73,7 @@ class ThubanApplication(wxApp, Publisher
         if self.splash is not None:
             self.splash.Show()
         self.read_startup_files()
+        self.init_extensions()
         self.top = self.CreateMainWindow()
         # The session was alredy created above and we need to get the
         # map into the mainwindow.  maps_changed does that.
@@ -121,6 +124,11 @@ class ThubanApplication(wxApp, Publisher
         else:
             # There's no .thuban directory
             sys.stderr.write(_("No ~/.thuban directory\n"))
+
+    def init_extensions(self):
+        """Call initialization callbacks for allregistered extensions."""
+        for ext in ext_registry:
+            ext.init_ext()
 
     def splash_screen(self):
         """Create and return a splash screen.
Index: Thuban/UI/extensionregistry.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/extensionregistry.py,v
retrieving revision 1.1
diff -u -3 -p -r1.1 extensionregistry.py
--- Thuban/UI/extensionregistry.py	28 Sep 2004 19:13:21 -0000	1.1
+++ Thuban/UI/extensionregistry.py	24 Feb 2005 22:33:19 -0000
@@ -23,13 +23,16 @@ __version__ = "$Revision: 1.1 $"
 # $Source: /thubanrepository/thuban/Thuban/UI/extensionregistry.py,v $
 # $Id: extensionregistry.py,v 1.1 2004/09/28 19:13:21 jan Exp $
 
+from Thuban import _
+
 class ExtensionDesc:
 
     """
     A description of a Thuban Extension.
     """
 
-    def __init__(self, name, version, authors, copyright, desc):
+    def __init__(self, name, version, authors, copyright, desc,
+                 init_callback = None):
         """
         Initialize a new Thuban Extension information.
 
@@ -50,13 +53,39 @@ class ExtensionDesc:
                          Converts GNS (Geographical Name Service of NIMA)
                          to Shapefile format and displays the data.
                          ''')
-
+        init_callback -- a callback method that is executed if not
+                         None. This method should contain gui specific
+                         initializations of the extension.
+                         Default is None.
+
+                         This callback should return None if
+                         the intialisation as successful. Else
+                         a string describing the problems during
+                         intialization.
         """
         self.name = name
         self.version = version
         self.authors = authors
         self.copyright = copyright
         self.desc = desc
+        self.init_callback = init_callback
+        self.status = _("Initialization not yet requested.")
+
+    def init_ext(self):
+        """Execute the init callback for the extension.
+
+        Do nothing if the callback is None.
+
+        It is expected that the callback function returns
+        None if all was OK and a string if something was wrong.
+        The string is believed to describe the problems.
+        """
+        if self.init_callback is not None:
+            result = self.init_callback()
+            if result is not None:
+                self.status = result
+            else:
+                self.status = _("Initialization successful.")
 
 class ExtensionRegistry:
 
Index: Thuban/UI/about.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/about.py,v
retrieving revision 1.20
diff -u -3 -p -r1.20 about.py
--- Thuban/UI/about.py	20 Jan 2005 13:14:14 -0000	1.20
+++ Thuban/UI/about.py	24 Feb 2005 22:33:19 -0000
@@ -125,6 +125,8 @@ class About(wxDialog):
                 for author in ext.authors:
                     text+= '\t%s\n' % author
                 text += ext.desc
+                text += '\n'
+                text += 'Status: %s' % ext.status
                 text += '\n\n'
         else:
             text += _('\tNone registered.\n')

--r5Pyd7+fXNt84Ff3--




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)