[tor-commits] [stem/master] Use the more idiomatic staticmethod decorator
atagar at torproject.org
atagar at torproject.org
Mon May 6 01:09:36 UTC 2013
commit 3d047cb483f0692ef94b5b0cdac478da448957b0
Author: Sean Robinson <seankrobinson at gmail.com>
Date: Fri May 3 17:28:48 2013 -0700
Use the more idiomatic staticmethod decorator
This is just a coding style change and not a functional change. Funnily
enough, there was already one of these decorators added in
commit 5da6b9790da266f9. So, this standardizes on the more Pythonic
form.
Signed-off-by: Sean Robinson <seankrobinson at gmail.com>
---
stem/control.py | 5 ++---
stem/response/__init__.py | 3 +--
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/stem/control.py b/stem/control.py
index 6a7b0ed..2312712 100644
--- a/stem/control.py
+++ b/stem/control.py
@@ -617,6 +617,7 @@ class Controller(BaseController):
BaseController and provides a more user friendly API for library users.
"""
+ @staticmethod
def from_port(address = "127.0.0.1", port = 9051):
"""
Constructs a :class:`~stem.socket.ControlPort` based Controller.
@@ -637,6 +638,7 @@ class Controller(BaseController):
control_port = stem.socket.ControlPort(address, port)
return Controller(control_port)
+ @staticmethod
def from_socket_file(path = "/var/run/tor/control"):
"""
Constructs a :class:`~stem.socket.ControlSocketFile` based Controller.
@@ -651,9 +653,6 @@ class Controller(BaseController):
control_socket = stem.socket.ControlSocketFile(path)
return Controller(control_socket)
- from_port = staticmethod(from_port)
- from_socket_file = staticmethod(from_socket_file)
-
def __init__(self, control_socket):
super(Controller, self).__init__(control_socket)
diff --git a/stem/response/__init__.py b/stem/response/__init__.py
index 1f2957a..92e4527 100644
--- a/stem/response/__init__.py
+++ b/stem/response/__init__.py
@@ -135,6 +135,7 @@ class ControlMessage(object):
never empty.
"""
+ @staticmethod
def from_str(content):
"""
Provides a ControlMessage for the given content.
@@ -146,8 +147,6 @@ class ControlMessage(object):
return stem.socket.recv_message(StringIO.StringIO(content))
- from_str = staticmethod(from_str)
-
def __init__(self, parsed_content, raw_content):
if not parsed_content:
raise ValueError("ControlMessages can't be empty")
More information about the tor-commits
mailing list