[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Changing @uses_settings to use keyword argument



commit 0764a99b75a55c94545a8e7ff90408366966e079
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Apr 19 19:07:51 2014 -0700

    Changing @uses_settings to use keyword argument
    
    Our @uses_settings passed along the configuration as the function's first
    argument. This is well and good for functions, but for methods that meant we no
    longer started with 'self'. This is really, really weird in the python world so
    changing the annotation to pass the value along as a keyword argument.
---
 stem/interpretor/__init__.py     |    2 +-
 stem/interpretor/autocomplete.py |    2 +-
 stem/interpretor/commands.py     |    2 +-
 stem/util/conf.py                |    4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/stem/interpretor/__init__.py b/stem/interpretor/__init__.py
index 5e03c2c..b4662d4 100644
--- a/stem/interpretor/__init__.py
+++ b/stem/interpretor/__init__.py
@@ -31,7 +31,7 @@ uses_settings = stem.util.conf.uses_settings('stem_interpretor', settings_path)
 
 
 @uses_settings
-def msg(config, message, **attr):
+def msg(message, config, **attr):
   return config.get(message).format(**attr)
 
 
diff --git a/stem/interpretor/autocomplete.py b/stem/interpretor/autocomplete.py
index a94c09d..7007be6 100644
--- a/stem/interpretor/autocomplete.py
+++ b/stem/interpretor/autocomplete.py
@@ -12,7 +12,7 @@ except ImportError:
 
 
 @uses_settings
-def _get_commands(config, controller):
+def _get_commands(controller, config):
   """
   Provides commands recognized by tor.
   """
diff --git a/stem/interpretor/commands.py b/stem/interpretor/commands.py
index e5b3e97..3a75f6c 100644
--- a/stem/interpretor/commands.py
+++ b/stem/interpretor/commands.py
@@ -34,7 +34,7 @@ class ControlInterpretor(object):
     self.received_events.append(event)
 
   @uses_settings
-  def do_help(config, self, arg):
+  def do_help(self, arg, config):
     """
     Performs the '/help' operation, giving usage information for the given
     argument or a general summary if there wasn't one.
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 420d4e6..c232a2a 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -239,7 +239,7 @@ def uses_settings(handle, path, lazy_load = True):
   """
   Provides a function that can be used as an annotation for other functions
   that require settings to be loaded. Functions with this annotation will be
-  provided with the configuration as its first argument.
+  provided with the configuration as its 'config' keyword argument.
 
   ::
 
@@ -273,7 +273,7 @@ def uses_settings(handle, path, lazy_load = True):
         config.load(path)
         config.set('settings_loaded', 'true')
 
-      return func(config, *args, **kwargs)
+      return func(*args, config = config, **kwargs)
 
     return wrapped
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits