Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Consistency in when a period is added to a doc string, and doc'ing of…
Browse files Browse the repository at this point in the history
… http methods.
  • Loading branch information
bbangert committed Jun 17, 2015
1 parent e7e58e9 commit 8b48ff3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
13 changes: 6 additions & 7 deletions autopush/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def get_router_table(tablename="router", read_throughput=5,
"""Get the main router table object
Creates the table if it doesn't already exist, otherwise returns the
existing table
existing table.
"""
db = DynamoDBConnection()
Expand All @@ -61,7 +61,7 @@ def get_storage_table(tablename="storage", read_throughput=5,
"""Get the main storage table object
Creates the table if it doesn't already exist, otherwise returns the
existing table
existing table.
"""
db = DynamoDBConnection()
Expand Down Expand Up @@ -105,7 +105,7 @@ class Storage(object):
def __init__(self, table, metrics):
"""Create a new Storage object
:param table: :class:`Table` object
:param table: :class:`Table` object.
:param metrics: Metrics object that implements the
:class:`autopush.metrics.IMetrics` interface.
Expand Down Expand Up @@ -180,7 +180,7 @@ class Router(object):
def __init__(self, table, metrics):
"""Create a new Router object
:param table: :class:`Table` object
:param table: :class:`Table` object.
:param metrics: Metrics object that implements the
:class:`autopush.metrics.IMetrics` interface.
Expand Down Expand Up @@ -212,8 +212,7 @@ def get_uaid(self, uaid):
raise ItemNotFound("uaid not found")

def register_user(self, data):
"""Attempt to register this user if it doesn't already exist or
this is the latest connection.
"""Register this user
If a record exists with a newer ``connected_at``, then the user will
not be registered.
Expand Down Expand Up @@ -259,7 +258,7 @@ def register_user(self, data):
raise

def clear_node(self, item):
"""Given a router item, remove the node_id from it.
"""Given a router item and remove the node_id
The node_id will only be cleared if the ``connected_at`` matches up
with the item's ``connected_at``.
Expand Down
18 changes: 13 additions & 5 deletions autopush/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class Notification(namedtuple("Notification", "version data channel_id")):

def parse_request_params(request):
"""Parse request params from either the body or query as needed and
return them.
return them
:returns: Tuple of (version, data).
Expand Down Expand Up @@ -452,9 +452,9 @@ class RegistrationHandler(AutoendpointHandler):
#############################################################
@cyclone.web.asynchronous
def get(self, uaid=""):
"""HTTP GET Handler
"""HTTP GET
Returns router type/data for the UAID.
Retrieves the router type/data for a UAID.
"""
if not self._validate_auth(uaid):
Expand All @@ -471,7 +471,11 @@ def get(self, uaid=""):

@cyclone.web.asynchronous
def post(self, uaid=""):
"""HTTP POST Handler for endpoint generation"""
"""HTTP POST
Endpoint generation and optionally router type/data registration.
"""
self.start_time = time.time()
self.add_header("Content-Type", "application/json")
params = self._load_params()
Expand Down Expand Up @@ -511,7 +515,11 @@ def post(self, uaid=""):

@cyclone.web.asynchronous
def put(self, uaid=""):
"""HTTP PUT Handler"""
"""HTTP PUT
Update router type/data for a UAID.
"""
self.start_time = time.time()

if not self._validate_auth(uaid):
Expand Down
2 changes: 1 addition & 1 deletion autopush/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class EliotObserver(object):
"""A Twisted log observer that logs to Eliot."""
"""A Twisted log observer that logs to Eliot"""
def __init__(self):
"""Create the Eliot Observer"""
if os.environ.get("SENTRY_DSN"):
Expand Down
3 changes: 2 additions & 1 deletion autopush/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@


class IgnoreBody(Protocol):
"""A protocol that discards any data it receives.
"""A protocol that discards any data it receives
This is necessary to support persistent HTTP connections. If the
response body is never read using ``Response.deliverBody``, or
``stopProducing()`` is called, the connection will not be reused.
"""
def __init__(self, response, deferred):
self.response = response
Expand Down
2 changes: 1 addition & 1 deletion autopush/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(self,

def update(self, **kwargs):
"""Update the arguments, if a ``crypto_key`` is in kwargs then the
``self.fernet`` attribute will be initialized."""
``self.fernet`` attribute will be initialized"""
for key, val in kwargs.items():
if key == "crypto_key":
self.fernet = Fernet(val)
Expand Down
2 changes: 1 addition & 1 deletion autopush/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
class AutopushSSLContextFactory(ssl.DefaultOpenSSLContextFactory):
"""A SSL context factory"""
def cacheContext(self):
"""Setup the main context factory with custom SSL settings."""
"""Setup the main context factory with custom SSL settings"""
if self._context is None:
ctx = self._contextFactory(self.sslmethod)

Expand Down
7 changes: 5 additions & 2 deletions autopush/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def validate_hash(key, payload, hashed):


def generate_hash(key, payload):
"""Generate a HMAC for the uaid using the secret. Returns the HMAC hash
and the nonce used as a tuple (nonce, hash)."""
"""Generate a HMAC for the uaid using the secret
:returns: HMAC hash and the nonce used as a tuple (nonce, hash).
"""
h = hmac.new(key=key, msg=payload, digestmod=hashlib.sha256)
return h.hexdigest()

0 comments on commit 8b48ff3

Please sign in to comment.