Jelajahi Sumber

[Doc] Docstrings of neurons package

monf 8 tahun lalu
induk
melakukan
42f02d9a1f

+ 13 - 2
neurons/gmail_checker/gmail_checker.py

@@ -58,6 +58,15 @@ class Gmail_checker(NeuronModule):
     @staticmethod
     def try_parse(header, encoding):
 
+        """
+            Verifying the Encoding and return unicode
+
+            :param header: the header to decode
+            :param encoding: the targeted encoding
+            :return: either 'ASCII' or 'ISO-8859-1' or 'UTF-8'
+
+            .. raises:: UnicodeDecodeError
+        """
         if encoding is None:
             encoding = 'ASCII'
         try:
@@ -70,8 +79,10 @@ class Gmail_checker(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: MissingParameterException
         """
         if self.username is None:
             raise MissingParameterException("Username parameter required")

+ 3 - 0
neurons/kill_switch/kill_switch.py

@@ -4,6 +4,9 @@ from core.NeuronModule import NeuronModule
 
 
 class Kill_switch(NeuronModule):
+    """
+        Class used to exit Kalliope process from system command
+    """
     def __init__(self, **kwargs):
         super(Kill_switch, self).__init__(**kwargs)
         sys.exit()

+ 10 - 2
neurons/neurotransmitter/neurotransmitter.py

@@ -19,6 +19,11 @@ class Neurotransmitter(NeuronModule):
             self.get_audio_from_stt(callback=self.callback)
 
     def callback(self, audio):
+        """
+            The callback used by the STT module to get the linked synapse
+
+        :param audio: the audio to play by STT
+        """
         logger.debug("Neurotransmitter, receiver audio from STT: %s" % audio)
         # print self.links
         # set a bool to know if we have found a valid answer
@@ -35,9 +40,12 @@ class Neurotransmitter(NeuronModule):
 
     def _links_content_ok(self):
         """
-        Check the content of the links parameter
-        :return:
+            Check if received links are ok to perform operations
+            :return: true if links are ok, raise an exception otherwise
+
+            .. raises:: MissingParameterException
         """
+
         if self.links is None:
             raise MissingParameterException("links parameter required and must contain at least one link")
         if self.default is None:

+ 4 - 2
neurons/openweathermap/Openweathermap.py

@@ -114,8 +114,10 @@ class Openweathermap(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: NotImplementedError
         """
         if self.api_key is None:
             raise NotImplementedError("OpenWeatherMap neuron needs an api_key")

+ 8 - 7
neurons/push_message/Push_message.py

@@ -10,11 +10,10 @@ class Push_message(NeuronModule):
     """
     def __init__(self, **kwargs):
         """
-        Send a push message to an android phone via Pushetta API
-        :param message: Message to send
-        :param api_key: The Pushetta service secret token
-        :param channel_name: Pushetta channel name
-        :return:
+            Send a push message to an android phone via Pushetta API
+            :param message: Message to send
+            :param api_key: The Pushetta service secret token
+            :param channel_name: Pushetta channel name
         """
         super(Push_message, self).__init__(**kwargs)
 
@@ -29,8 +28,10 @@ class Push_message(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: NotImplementedError
         """
         if self.message is None:
             raise NotImplementedError("Pushetta neuron needs message to send")

+ 4 - 2
neurons/say/say.py

@@ -12,8 +12,10 @@ class Say(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: MissingParameterException
         """
         if self.message is None:
             raise MissingParameterException("You must specify a message string or a list of messages as parameter")

+ 4 - 2
neurons/script/script.py

@@ -16,8 +16,10 @@ class Script(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: MissingParameterException, InvalidParameterException
         """
         if self.path is None:
             raise MissingParameterException("You must provide a script path.")

+ 15 - 2
neurons/shell/shell.py

@@ -8,6 +8,13 @@ logger = logging.getLogger("kalliope")
 
 
 class AsyncShell(threading.Thread):
+
+    """
+
+        Class used to run an asynchrone Shell command
+
+        .. notes:: Impossible to get the success code of the command
+    """
     def __init__(self, cmd):
         self.stdout = None
         self.stderr = None
@@ -24,6 +31,10 @@ class AsyncShell(threading.Thread):
 
 
 class Shell(NeuronModule):
+
+    """
+        Run a shell command in a synchron mode
+    """
     def __init__(self, **kwargs):
         super(Shell, self).__init__(**kwargs)
 
@@ -50,8 +61,10 @@ class Shell(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: MissingParameterException
         """
         if self.cmd is None:
             raise MissingParameterException("cmd parameter required")

+ 4 - 2
neurons/sleep/sleep.py

@@ -14,8 +14,10 @@ class Sleep(NeuronModule):
 
         def _is_parameters_ok(self):
             """
-            Check if received parameters are ok to perform operations in the neuron
-            :return: true if parameters are ok, raise an exception otherwise
+                Check if received parameters are ok to perform operations in the neuron
+                :return: true if parameters are ok, raise an exception otherwise
+
+                .. raises:: MissingParameterException
             """
             if self.seconds is None:
                 raise MissingParameterException("You must set a number of seconds as parameter")

+ 0 - 1
neurons/systemdate/systemdate.py

@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import time
 
 from core.NeuronModule import NeuronModule

+ 4 - 2
neurons/tasker_autoremote/tasker_autoremote.py

@@ -28,8 +28,10 @@ class Tasker_autoremote(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: MissingParameterException
         """
         if self.key is None:
             raise MissingParameterException("key parameter required")

+ 4 - 2
neurons/twitter/Twitter.py

@@ -30,8 +30,10 @@ class Twitter(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: InvalidParameterException
         """
         if self.consumer_key is None:
             raise InvalidParameterException("Twitter needs a consumer_key")

+ 4 - 2
neurons/wake_on_lan/Wake_on_lan.py

@@ -31,8 +31,10 @@ class Wake_on_lan(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return: true if parameters are ok, raise an exception otherwise
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: InvalidParameterException, MissingParameterException
         """
         # check we provide a mac address
         if self.mac_address is None:

+ 5 - 2
neurons/wikipedia/Wikipedia.py

@@ -57,9 +57,12 @@ class Wikipedia(NeuronModule):
 
     def _is_parameters_ok(self):
         """
-        Check if received parameters are ok to perform operations in the neuron
-        :return:
+            Check if received parameters are ok to perform operations in the neuron
+            :return: true if parameters are ok, raise an exception otherwise
+
+            .. raises:: InvalidParameterException
         """
+
         if self.query is None:
             raise InvalidParameterException("Wikipedia needs a query")
         if self.language is None: