[tor-commits] [stem/master] Renaming get_system_resolvers() to system_resolvers()

atagar at torproject.org atagar at torproject.org
Tue Sep 2 03:55:48 UTC 2014


commit abe6fc9d9caee79bcb3021d9942204e3ce63c54b
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Sep 1 20:24:41 2014 -0700

    Renaming get_system_resolvers() to system_resolvers()
---
 docs/tutorials/east_of_the_sun.rst |    4 ++--
 stem/util/connection.py            |   18 +++++++++++++++---
 stem/util/proc.py                  |    5 ++---
 stem/util/system.py                |    5 ++---
 test/integ/util/connection.py      |    4 ++--
 test/unit/util/connection.py       |   20 ++++++++++----------
 6 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/docs/tutorials/east_of_the_sun.rst b/docs/tutorials/east_of_the_sun.rst
index fa7635b..13ede2d 100644
--- a/docs/tutorials/east_of_the_sun.rst
+++ b/docs/tutorials/east_of_the_sun.rst
@@ -37,10 +37,10 @@ simple script that dumps Tor's present connections.
 
   import sys 
 
-  from stem.util.connection import get_connections, get_system_resolvers
+  from stem.util.connection import get_connections, system_resolvers
   from stem.util.system import pid_by_name
 
-  resolvers = get_system_resolvers()
+  resolvers = system_resolvers()
 
   if not resolvers:
     print "Stem doesn't support any connection resolvers on our platform."
diff --git a/stem/util/connection.py b/stem/util/connection.py
index 0c5b744..09acdeb 100644
--- a/stem/util/connection.py
+++ b/stem/util/connection.py
@@ -4,10 +4,12 @@
 """
 Connection and networking based utility functions.
 
+**Module Overview:**
+
 ::
 
   get_connections - quieries the connections belonging to a given process
-  get_system_resolvers - provides connection resolution methods that are likely to be available
+  system_resolvers - provides connection resolution methods that are likely to be available
   port_usage - brief description of the common usage for a port
 
   is_valid_ipv4_address - checks if a string is a valid IPv4 address
@@ -130,7 +132,7 @@ RESOLVER_FILTER = {
 def get_connections(resolver, process_pid = None, process_name = None):
   """
   Retrieves a list of the current connections for a given process. The provides
-  a list of Connection instances, which have four attributes...
+  a list of Connection instances, which have five attributes...
 
     * local_address (str)
     * local_port (int)
@@ -230,12 +232,16 @@ def get_connections(resolver, process_pid = None, process_name = None):
   return connections
 
 
-def get_system_resolvers(system = None):
+def system_resolvers(system = None):
   """
   Provides the types of connection resolvers likely to be available on this platform.
 
   .. versionadded:: 1.1.0
 
+  .. versionchanged:: 1.3.0
+     Renamed from get_system_resolvers() to system_resolvers(). The old name
+     still works as an alias, but will be dropped in Stem version 2.0.0.
+
   :param str system: system to get resolvers for, this is determined by
     platform.system() if not provided
 
@@ -619,3 +625,9 @@ def _cryptovariables_equal(x, y):
   return (
     _hmac_sha256(CRYPTOVARIABLE_EQUALITY_COMPARISON_NONCE, x) ==
     _hmac_sha256(CRYPTOVARIABLE_EQUALITY_COMPARISON_NONCE, y))
+
+# TODO: drop with stem 2.x
+# We renamed our methods to drop a redundant 'get_*' prefix, so alias the old
+# names for backward compatability.
+
+get_system_resolvers = system_resolvers
diff --git a/stem/util/proc.py b/stem/util/proc.py
index b05d283..85a7501 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -15,9 +15,8 @@ Dave Daeschler, Giampaolo Rodola' and is under the BSD license.
 **These functions are not being vended to stem users. They may change in the
 future, use them at your own risk.**
 
-.. deprecated:: 1.3.0
-   Many functions were previously named with a get_* prefix. Those names are
-   now aliases, and will be dropped in Stem version 2.0.0.
+**Note:** Many functions were previously named with a get_* prefix. Those names
+are now aliases, and will be dropped in Stem version 2.0.0.
 
 **Module Overview:**
 
diff --git a/stem/util/system.py b/stem/util/system.py
index 89eac3f..47023f4 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -6,9 +6,8 @@ Helper functions for working with the underlying system. These are mostly os
 dependent, only working on linux, osx, and bsd. In almost all cases they're
 best-effort, providing **None** if the lookup fails.
 
-.. deprecated:: 1.3.0
-   Many functions were previously named with a get_* prefix. Those names are
-   now aliases, and will be dropped in Stem version 2.0.0.
+**Note:** Many functions were previously named with a get_* prefix. Those names
+are now aliases, and will be dropped in Stem version 2.0.0.
 
 **Module Overview:**
 
diff --git a/test/integ/util/connection.py b/test/integ/util/connection.py
index 8883be2..589026a 100644
--- a/test/integ/util/connection.py
+++ b/test/integ/util/connection.py
@@ -7,7 +7,7 @@ import unittest
 
 import test.runner
 
-from stem.util.connection import get_connections, get_system_resolvers
+from stem.util.connection import get_connections, system_resolvers
 
 
 class TestConnection(unittest.TestCase):
@@ -21,7 +21,7 @@ class TestConnection(unittest.TestCase):
       test.runner.skip(self, '(DisableDebuggerAttachment is set)')
       return
 
-    for resolver in get_system_resolvers():
+    for resolver in system_resolvers():
       with runner.get_tor_socket():
         tor_pid = test.runner.get_runner().get_pid()
         connections = get_connections(resolver, process_pid = tor_pid)
diff --git a/test/unit/util/connection.py b/test/unit/util/connection.py
index f44a851..0ae6f9b 100644
--- a/test/unit/util/connection.py
+++ b/test/unit/util/connection.py
@@ -107,32 +107,32 @@ BSD_PROCSTAT_OUTPUT = """\
 class TestConnection(unittest.TestCase):
   @patch('stem.util.system.is_available')
   @patch('stem.util.proc.is_available')
-  def test_get_system_resolvers(self, proc_mock, is_available_mock):
+  def test_system_resolvers(self, proc_mock, is_available_mock):
     """
-    Checks the get_system_resolvers function.
+    Checks the system_resolvers function.
     """
 
     is_available_mock.return_value = True
     proc_mock.return_value = False
 
-    self.assertEqual([], stem.util.connection.get_system_resolvers('Windows'))
-    self.assertEqual([Resolver.LSOF], stem.util.connection.get_system_resolvers('Darwin'))
-    self.assertEqual([Resolver.LSOF], stem.util.connection.get_system_resolvers('OpenBSD'))
-    self.assertEqual([Resolver.BSD_SOCKSTAT, Resolver.BSD_PROCSTAT, Resolver.LSOF], stem.util.connection.get_system_resolvers('FreeBSD'))
-    self.assertEqual([Resolver.NETSTAT, Resolver.SOCKSTAT, Resolver.LSOF, Resolver.SS], stem.util.connection.get_system_resolvers('Linux'))
+    self.assertEqual([], stem.util.connection.system_resolvers('Windows'))
+    self.assertEqual([Resolver.LSOF], stem.util.connection.system_resolvers('Darwin'))
+    self.assertEqual([Resolver.LSOF], stem.util.connection.system_resolvers('OpenBSD'))
+    self.assertEqual([Resolver.BSD_SOCKSTAT, Resolver.BSD_PROCSTAT, Resolver.LSOF], stem.util.connection.system_resolvers('FreeBSD'))
+    self.assertEqual([Resolver.NETSTAT, Resolver.SOCKSTAT, Resolver.LSOF, Resolver.SS], stem.util.connection.system_resolvers('Linux'))
 
     proc_mock.return_value = True
-    self.assertEqual([Resolver.PROC, Resolver.NETSTAT, Resolver.SOCKSTAT, Resolver.LSOF, Resolver.SS], stem.util.connection.get_system_resolvers('Linux'))
+    self.assertEqual([Resolver.PROC, Resolver.NETSTAT, Resolver.SOCKSTAT, Resolver.LSOF, Resolver.SS], stem.util.connection.system_resolvers('Linux'))
 
     # check that calling without an argument is equivilant to calling for this
     # platform
 
-    self.assertEqual(stem.util.connection.get_system_resolvers(platform.system()), stem.util.connection.get_system_resolvers())
+    self.assertEqual(stem.util.connection.system_resolvers(platform.system()), stem.util.connection.system_resolvers())
 
     # check that lacking commands in our PATH drops them from the results
 
     is_available_mock.return_value = False
-    self.assertEqual([Resolver.PROC], stem.util.connection.get_system_resolvers('Linux'))
+    self.assertEqual([Resolver.PROC], stem.util.connection.system_resolvers('Linux'))
 
   def test_port_usage(self):
     """





More information about the tor-commits mailing list