[tor-commits] [stem/master] Renaming the Config update method to synchronize()

atagar at torproject.org atagar at torproject.org
Wed Jan 25 15:46:29 UTC 2012


commit 9e3834d80b0ae10f8ab5076e00186ddd346b39f5
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Jan 25 07:36:11 2012 -0800

    Renaming the Config update method to synchronize()
    
    Calling this method 'update()' has confused a couple people. It changes a
    dictionary to match the key/values in our current configuration. Calling
    this synchronize() makes more sense though now I should change the sync()
    method - that's next.
---
 stem/util/conf.py       |   13 +++++++------
 test/integ/util/conf.py |    2 +-
 test/unit/util/conf.py  |   18 +++++++++---------
 3 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/stem/util/conf.py b/stem/util/conf.py
index 63843e5..9250053 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -24,7 +24,7 @@ Config - Custom configuration.
   |- load - reads a configuration file
   |- save - writes the current configuration to a file
   |- clear - empties our loaded configuration contents
-  |- update - replaces mappings in a dictionary with the config's values
+  |- synchronize - replaces mappings in a dictionary with the config's values
   |- add_listener - notifies the given listener when an update occures
   |- clear_listeners - removes any attached listeners
   |- sync - keeps a dictionary synchronized with our config
@@ -143,7 +143,7 @@ class Config():
       # Information for what values fail to load and why are reported to
       # 'stem.util.log'.
       
-      user_config.update(ssh_config)
+      user_config.synchronize(ssh_config)
   """
   
   def __init__(self):
@@ -248,7 +248,7 @@ class Config():
     self._requested_keys = set()
     self._contents_lock.release()
   
-  def update(self, conf_mappings, limits = None):
+  def synchronize(self, conf_mappings, limits = None):
     """
     This takes a dictionary of 'config_key => default_value' mappings and
     changes the values to reflect our current configuration. This will leave
@@ -314,8 +314,9 @@ class Config():
   
   def sync(self, config_dict, interceptor = None):
     """
-    Synchronizes a dictionary with our current configuration (like the 'update'
-    method), and registers it to be updated whenever our configuration changes.
+    Synchronizes a dictionary with our current configuration (like the
+    'synchronize' method), and registers it to be updated whenever our
+    configuration changes.
     
     If an interceptor is provided then this is called just prior to assigning
     new values to the config_dict. The interceptor function is expected to
@@ -344,7 +345,7 @@ class Config():
   def unused_keys(self):
     """
     Provides the configuration keys that have never been provided to a caller
-    via the get, get_value, or update methods.
+    via the get, get_value, or synchronize methods.
     
     Returns:
       set of configuration keys we've loaded but have never been requested
diff --git a/test/integ/util/conf.py b/test/integ/util/conf.py
index 6ac37c3..e6dfedb 100644
--- a/test/integ/util/conf.py
+++ b/test/integ/util/conf.py
@@ -72,7 +72,7 @@ class TestConf(unittest.TestCase):
     
     user_config = stem.util.conf.get_config("integ_testing")
     user_config.load(CONF_PATH)
-    user_config.update(ssh_config)
+    user_config.synchronize(ssh_config)
     
     self.assertEquals("atagar", ssh_config["login.user"])
     self.assertEquals("pepperjack_is_awesome!", ssh_config["login.password"])
diff --git a/test/unit/util/conf.py b/test/unit/util/conf.py
index 3e59a7c..7df0402 100644
--- a/test/unit/util/conf.py
+++ b/test/unit/util/conf.py
@@ -35,9 +35,9 @@ class TestConf(unittest.TestCase):
     test_config.clear()
     self.assertEquals([], test_config.keys())
   
-  def test_update(self):
+  def test_synchronize(self):
     """
-    Tests the update method.
+    Tests the synchronize method.
     """
     
     my_config = {
@@ -57,17 +57,17 @@ class TestConf(unittest.TestCase):
     test_config.set("list_value", "c", False)
     test_config.set("map_value", "foo => bar")
     
-    test_config.update(my_config)
+    test_config.synchronize(my_config)
     self.assertEquals(True, my_config["bool_value"])
     self.assertEquals(11, my_config["int_value"])
     self.assertEquals("world", my_config["str_value"])
     self.assertEquals(["a", "b", "c"], my_config["list_value"])
     self.assertEquals({"foo": "bar"}, my_config["map_value"])
   
-  def test_update_type_mismatch(self):
+  def test_synchronize_type_mismatch(self):
     """
-    Tests the update method when the config file has missing entries or the
-    wrong types.
+    Tests the synchronize method when the config file has missing entries or
+    the wrong types.
     """
     
     my_config = {
@@ -83,7 +83,7 @@ class TestConf(unittest.TestCase):
     test_config.set("int_value", "11a")
     test_config.set("map_value", "foo bar")
     
-    test_config.update(my_config)
+    test_config.synchronize(my_config)
     self.assertEquals(False, my_config["bool_value"])
     self.assertEquals(5, my_config["int_value"])
     self.assertEquals("hello", my_config["str_value"])
@@ -132,11 +132,11 @@ class TestConf(unittest.TestCase):
     test_config.sync(my_config)
     self.assertEquals(True, my_config["bool_value"])
     
-    # check a basic update
+    # check a basic synchronize
     test_config.set("str_value", "me")
     self.assertEquals("me", my_config["str_value"])
     
-    # update with a type mismatch, should keep the old value
+    # synchronize with a type mismatch, should keep the old value
     test_config.set("int_value", "7a")
     self.assertEquals(5, my_config["int_value"])
     



More information about the tor-commits mailing list