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

[tor-commits] [stem/master] Fix a bug because of which get_conf wouldn't work for HiddenService*



commit ffd68ccc660a92cc3cff61ae8baafebb6799e52e
Author: Ravi Chandra Padmala <neenaoffline@xxxxxxxxx>
Date:   Mon Jul 2 09:39:35 2012 +0530

    Fix a bug because of which get_conf wouldn't work for HiddenService*
---
 stem/control.py      |   10 +++++++---
 stem/util/control.py |    6 ++----
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/stem/control.py b/stem/control.py
index 94427a7..61dd453 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -574,7 +574,10 @@ class Controller(BaseController):
     # automagically change the requested parameter if it's context sensitive
     # and cannot be returned on it's own.
     param = param.lower()
-    return self.get_conf_map(self._mapped_config_keys.get(param, param), default, multiple)[param]
+    entries = self.get_conf_map(self._mapped_config_keys.get(param, param), default, multiple)
+    if param in self._mapped_config_keys:
+      return entries[stem.util.control.case_insensitive_lookup(entries, param)]
+    else: return entries[param]
   
   def get_conf_map(self, param, default = UNDEFINED, multiple = True):
     """
@@ -629,13 +632,14 @@ class Controller(BaseController):
       response = self.msg("GETCONF %s" % ' '.join(param))
       stem.response.convert("GETCONF", response)
       
+      lookup = stem.util.control.case_insensitive_lookup
       # map the entries back to the parameters given so the capitalization
       # matches. Note: when the same configuration key is provided multiple
       # times, this uses the first one and ignores the rest.
       for key in response.entries:
         if not key.lower() in self._mapped_config_keys:
-          response.entries[stem.util.control.case_insensitive_lookup(param, key)] = response.entries[key]
-          if key != stem.util.control.case_insensitive_lookup(param, key): del response.entries[key]
+          response.entries[lookup(param, key)] = response.entries[key]
+          if key != lookup(param, key): del response.entries[key]
       
       requested_params = set(param)
       reply_params = set(response.entries.keys())
diff --git a/stem/util/control.py b/stem/util/control.py
index f6b0da0..5ea2efe 100644
--- a/stem/util/control.py
+++ b/stem/util/control.py
@@ -7,20 +7,18 @@ Helper functions utilized by the controller classes.
   case_insensitive_lookup - does case insensitive lookups on python dictionaries
 """
 
-def case_insensitive_lookup(lst, key, start=None, stop=None):
+def case_insensitive_lookup(lst, key):
   """
   Returns the first value equal to key in lst while ignoring case.
   
   :param list lst: list of strings
   :param str key: string to be looked up
-  :param int start: index from where the lookup should begin
-  :param int stop: index where the lookup ends
   
   :returns: case-insensitive equivalent of key in lst
   
   :raises: ValueError if such a key doesn't exist
   """
   
-  for i in lst[start:stop]:
+  for i in lst:
     if i.lower() == key.lower():
       return i



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