Author: remi
Date: 2009-03-23 12:22:08 +0100 (Mon, 23 Mar 2009)
New Revision: 4177

Modified:
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetDescription.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetParameter.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetToken.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetsContainer.py
Log:
* added doc comments.

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
      2009-03-23 10:18:22 UTC (rev 4176)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/Gadget.py
      2009-03-23 11:22:08 UTC (rev 4177)
@@ -2,6 +2,10 @@
 #    Remi Jocaille <[email protected]>
 #    Distributed under the terms of the GNU General Public License
 #    http://www.gnu.org/copyleft/gpl.html
+#
+#    This module is highly inspired by a "gadget framework"  written by
+#    "Yoran Brault" <http://artisan.karma-lab.net>
+#
 
 import os
 import threading
@@ -150,11 +154,12 @@
         self.__onGadgetStoppedCallback = None
 
     # 
--------------------------------------------------------------------------
-    #
+    # Get the directory path where this gadget is uncompressed.
     # 
--------------------------------------------------------------------------
     def getWorkingPath(self):
+        """Get the directory path where this gadget is uncompressed.
+        @return: A directory path as string.
         """
-        """
         return self.__workingPath
 
     # 
--------------------------------------------------------------------------
@@ -257,18 +262,17 @@
     # 
==========================================================================
 
     # 
--------------------------------------------------------------------------
-    #
+    # Update the i18n objects list of the gadget.
     # 
--------------------------------------------------------------------------
     def __updateI18nList(self):
+        """Update the i18n objects list of the gadget.
         """
-        """
         self.__i18nList = {}
         languages = ["en", "fr", "nl", "es", "it", "pt", "ar", "da", "de", 
"no",
             "sv",]
         language = self.__parent.getLanguage()
         if language not in languages:
             languages.append(language)
-        # TODO : Add default language ... i18n Modif
         for language in languages:
             i18n = I18n()
             i18n.setPoDirectory(os.path.join(self.__workingPath, "resources"))
@@ -277,11 +281,15 @@
             self.__i18nList[language] = i18n
 
     # 
--------------------------------------------------------------------------
-    #
+    # Translate a message with the current language of the gadgets container.
     # 
--------------------------------------------------------------------------
     def tr(self, message, *arguments):
+        """Translate a message with the current language of the gadgets
+        container.
+        @param message: Message to translate.
+        @param arguments: Arguments to pass in the message.
+        @return: The translated message.
         """
-        """
         result = self.__i18nList[self.__parent.getLanguage()].tr(message,
             *arguments)
         result = result.replace("\\''", "'")
@@ -290,11 +298,15 @@
         return result
 
     # 
--------------------------------------------------------------------------
-    #
+    # Translate a message with a specific language.
     # 
--------------------------------------------------------------------------
     def tr2(self, language, message, *arguments):
+        """Translate a message with a specific language.
+        @param language: Language of the traduction.
+        @param message: Message to translate.
+        @param arguments: Arguments to pass in the message.
+        @return: The translated message.
         """
-        """
         if language in self.__i18nList.keys():
             result = self.__i18nList[language].tr(message, *arguments)
         else:
@@ -310,79 +322,103 @@
     # 
==========================================================================
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget notification event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetNotificationCallback(self, funct):
+        """Set the gadget notification event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetNotification(gadget, instanceParameters, messageId, *args):
+            pass
         """
-        """
         self.__onGadgetNotificationCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget message event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetMessageCallback(self, funct):
+        """Set the gadget message event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetMessage(gadget, instanceParameters, message):
+            pass
         """
-        """
         self.__onGadgetMessageCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget error event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetErrorCallback(self, funct):
+        """Set the gadget error event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetError(gadget, instanceParameters, *messagesList):
+            pass
         """
-        """
         self.__onGadgetErrorCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget trace event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetTraceCallback(self, funct):
+        """Set the gadget trace event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetTrace(gadget, instanceParameters, *messagesList):
+            pass
         """
-        """
         self.__onGadgetTraceCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget starting event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetStartingCallback(self, funct):
+        """Set the gadget starting event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetStarting(gadget, instanceParameters):
+            pass
         """
-        """
         self.__onGadgetStartingCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget stopped event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetStoppedCallback(self, funct):
+        """Set the gadget stopped event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetStopped(gadget, instanceParameters):
+            pass
         """
-        """
         self.__onGadgetStoppedCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Event on gadget interpreter started.
     # 
--------------------------------------------------------------------------
     def __onInterpreterStarted(self):
+        """Event on gadget interpreter started.
         """
-        """
         if self.__onGadgetStartingCallback != None:
             self.__onGadgetStartingCallback(self, 
self.__gadgetInstanceParameters)
-        print "GADGET STARTING", self.__gadgetInstanceParameters
 
     # 
--------------------------------------------------------------------------
-    #
+    # Event on gadget interpreter stopped.
     # 
--------------------------------------------------------------------------
     def __onInterpreterStopped(self):
+        """Event on gadget interpreter stopped.
         """
-        """
         if self.__onGadgetStoppedCallback != None:
             self.__onGadgetStoppedCallback(self, 
self.__gadgetInstanceParameters)
-        print "GADGET STOPPED", self.__gadgetInstanceParameters
 
     # 
--------------------------------------------------------------------------
-    #
+    # Event on gadget interpreter notification.
     # 
--------------------------------------------------------------------------
     def __onInterpreterNotification(self, messageId, *args):
+        """Event on gadget interpreter notification.
+        @param messageId: Message identifiant as string.
+        @param args: Arguments of the notification.
         """
-        """
         messageId = messageId.lower()
         if messageId == "message":
             language = self.__gadgetInstanceParameters['language']
@@ -461,6 +497,7 @@
             self.__gadgetInterpreter.abort()
         self.__interpreterMutex.release()
 
+    # TODO: Create a class with the following functionalities.
     '''
     # 
==========================================================================
     # WEB GADGET Generators

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetDescription.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetDescription.py
   2009-03-23 10:18:22 UTC (rev 4176)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetDescription.py
   2009-03-23 11:22:08 UTC (rev 4177)
@@ -2,6 +2,10 @@
 #    Remi Jocaille <[email protected]>
 #    Distributed under the terms of the GNU General Public License
 #    http://www.gnu.org/copyleft/gpl.html
+#
+#    This module is highly inspired by a "gadget framework"  written by
+#    "Yoran Brault" <http://artisan.karma-lab.net>
+#
 
 import os
 

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetParameter.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetParameter.py
     2009-03-23 10:18:22 UTC (rev 4176)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetParameter.py
     2009-03-23 11:22:08 UTC (rev 4177)
@@ -2,6 +2,10 @@
 #    Remi Jocaille <[email protected]>
 #    Distributed under the terms of the GNU General Public License
 #    http://www.gnu.org/copyleft/gpl.html
+#
+#    This module is highly inspired by a "gadget framework"  written by
+#    "Yoran Brault" <http://artisan.karma-lab.net>
+#
 
 # 
------------------------------------------------------------------------------
 # Gadget parameter class.
@@ -32,11 +36,11 @@
         self.__update()
 
     # 
--------------------------------------------------------------------------
-    #
+    # Update the field values with the parameter dictionary.
     # 
--------------------------------------------------------------------------
     def __update(self):
+        """Update the field values with the parameter dictionary.
         """
-        """
         self.__name = self.__dictionary['name']
         self.__type = self.__dictionary['type']
         if self.__type.lower().find("enum") == 0:

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetToken.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetToken.py
 2009-03-23 10:18:22 UTC (rev 4176)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetToken.py
 2009-03-23 11:22:08 UTC (rev 4177)
@@ -2,6 +2,10 @@
 #    Remi Jocaille <[email protected]>
 #    Distributed under the terms of the GNU General Public License
 #    http://www.gnu.org/copyleft/gpl.html
+#
+#    This module is highly inspired by a "gadget framework"  written by
+#    "Yoran Brault" <http://artisan.karma-lab.net>
+#
 
 # 
------------------------------------------------------------------------------
 # Gadget token class.

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetsContainer.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetsContainer.py
    2009-03-23 10:18:22 UTC (rev 4176)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/applicationserver/gadget/GadgetsContainer.py
    2009-03-23 11:22:08 UTC (rev 4177)
@@ -2,6 +2,10 @@
 #    Remi Jocaille <[email protected]>
 #    Distributed under the terms of the GNU General Public License
 #    http://www.gnu.org/copyleft/gpl.html
+#
+#    This module is highly inspired by a "gadget framework"  written by
+#    "Yoran Brault" <http://artisan.karma-lab.net>
+#
 
 import os
 import threading
@@ -38,11 +42,15 @@
         self.__onGadgetUndeployedCallback = None
 
     # 
--------------------------------------------------------------------------
-    #
+    # Configure the locale values of the gadgets container.
     # 
--------------------------------------------------------------------------
     def setLocales(self, language, country, locutor, pitch):
+        """Configure the locale values of the gadgets container.
+        @param language: Language.
+        @param country: Country.
+        @param locutor: TTS locutor.
+        @param pitch: TTS pitch
         """
-        """
         self.__language = language
         self.__country = country
         self.__locutor = locutor
@@ -101,83 +109,110 @@
     # 
==========================================================================
 
     # 
--------------------------------------------------------------------------
-    #
+    # Add a gadgets directory to deploy.
     # 
--------------------------------------------------------------------------
     def addDirectory(self, directory):
+        """Add a gadgets directory to deploy.
+        @param directory: Directory path.
         """
-        """
         self.__autoDeployer.addDirectory(directory, [".tgf",])
 
     # 
--------------------------------------------------------------------------
-    #
+    # Remove a gadgets directory to deploy.
     # 
--------------------------------------------------------------------------
     def removeDirectory(self, directory):
+        """Remove a gadgets directory to deploy.
+        @param directory: Directory path.
         """
-        """
         self.__autoDeployer.removeDirectory(directory)
 
     # 
--------------------------------------------------------------------------
-    #
+    # Deploy the setted gadgets directories.
     # 
--------------------------------------------------------------------------
     def deploy(self):
+        """Deploy the setted gadgets directories.
         """
-        """
         self.__autoDeployer.deploy()
 
     # 
--------------------------------------------------------------------------
-    #
+    # Undeploy the setted gadgets directories.
     # 
--------------------------------------------------------------------------
     def undeploy(self):
+        """Undeploy the setted gadgets directories.
         """
-        """
         self.__autoDeployer.undeploy()
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the directory deployed event callback.
     # 
--------------------------------------------------------------------------
     def setOnDirectoryDeployedCallback(self, funct):
+        """Set the directory deployed event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onDirectoryDeployed(observerName):
+            pass
         """
-        """
         self.__autoDeployer.setOnDirectoryDeployedCallback(funct)
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the directory undeployed event callback.
     # 
--------------------------------------------------------------------------
     def setOnDirectoryUndeployedCallback(self, funct):
+        """Set the directory undeployed event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onDirectoryUndeployed(observerName):
+            pass
         """
-        """
         self.__autoDeployer.setOnDirectoryUndeployedCallback(funct)
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget deployed event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetDeployedCallback(self, funct):
+        """Set the gadget deployed event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetDeployed(gadget, gadgetWorkingPath):
+            pass
         """
-        """
         self.__onGadgetDeployedCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget deployment error event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetDeploymentErrorCallback(self, funct):
+        """Set the gadget deployment error event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetDeploymentError(observerName, gadgetFileName, message):
+            pass
         """
-        """
         self.__onGadgetDeploymentErrorCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Set the gadget undeployed event callback.
     # 
--------------------------------------------------------------------------
     def setOnGadgetUndeployedCallback(self, funct):
+        """Set the gadget undeployed event callback.
+        @param funct: Function pointer.
+        Function prototype:
+        def onGadgetUndeployed(gadget, gadgetWorkingPath):
+            pass
         """
-        """
         self.__onGadgetUndeployedCallback = funct
 
     # 
--------------------------------------------------------------------------
-    #
+    # Event on plugin deployed.
     # 
--------------------------------------------------------------------------
     def __onPluginDeployed(self, observerName, fileName, pluginPath, 
pluginName):
+        """Event on plugin deployed.
+        @param observerName: Directory observer name.
+        @param fileName: Plugin file name.
+        @param pluginPath: Path of the uncompressed plugin.
+        @param pluginName: Name of the plugin.
+        @return: If the plugin structure is correct or not.
         """
-        """
         gadget, msg = self.__buildGadget(observerName, fileName, pluginPath,
             pluginName)
         if gadget != None:
@@ -192,11 +227,15 @@
         return result
 
     # 
--------------------------------------------------------------------------
-    #
+    # Event on plugin undeployed.
     # 
--------------------------------------------------------------------------
     def __onPluginUndeployed(self, observerName, fileName, pluginPath, 
pluginName):
+        """Event on plugin undeployed.
+        @param observerName: Directory observer name.
+        @param fileName: Plugin file name.
+        @param pluginPath: Path of the uncompressed plugin.
+        @param pluginName: Name of the plugin.
         """
-        """
         # Get the gadget object
         for gadget in self.__gadgets:
             if gadget.getWorkingPath() == pluginPath:
@@ -207,11 +246,13 @@
                 break
 
     # 
--------------------------------------------------------------------------
-    #
+    # Event on plugin deployment error.
     # 
--------------------------------------------------------------------------
     def __onPluginDeploymentError(self, observerName, pluginName):
+        """Event on plugin deployment error.
+        @param observerName: Directory observer name.
+        @param pluginPath: Path of the uncompressed plugin.
         """
-        """
         msg = "Invalid gadget file"
         if self.__onGadgetDeploymentErrorCallback != None:
             self.__onGadgetDeploymentErrorCallback(observerName, pluginName,
@@ -222,11 +263,18 @@
     # 
==========================================================================
 
     # 
--------------------------------------------------------------------------
-    #
+    # Build a gadget object from a deployed plugin.
     # 
--------------------------------------------------------------------------
     def __buildGadget(self, observerName, fileName, pluginPath, pluginName):
+        """Build a gadget object from a deployed plugin.
+        @param observerName: Directory observer name.
+        @param fileName: Plugin file name.
+        @param pluginPath: Path of the uncompressed plugin.
+        @param pluginName: Name of the plugin.
+        @return: A tuple (<gadget>, "<Message>")
+        If the gadget can't be created, the "gadget" object will be None and
+        the message explains the reason.
         """
-        """
         # Check for "gadget.xml"
         gadgetXmlFile = os.path.join(pluginPath, "resources", "gadget.xml")
         gadgetXmlDict = XmlSerializer.deserializeEx(gadgetXmlFile)
@@ -266,11 +314,12 @@
         return gadget, "Ok"
 
     # 
--------------------------------------------------------------------------
-    #
+    # Destroy a gadget.
     # 
--------------------------------------------------------------------------
     def __destroyGadget(self, gadget):
+        """Destroy a gadget.
+        @param gadget: Gadget object to destroy.
         """
-        """
         # Remove this gadget from the container
         self.__mutex.acquire()
         gadget.stop()


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to