Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some code linting

- Added docstrings to some methods/functions
- Removed the SSL dumper debug code

Signed-off-by: Mansour <mansour@oxplot.com>
  • Loading branch information...
commit db7f9c224fd20e27525caa0775d5f6e6eb0eac9b 1 parent 630b87a
@oxplot authored
Showing with 13 additions and 29 deletions.
  1. +2 −1  README.md
  2. +11 −28 gcsms.py
View
3  README.md
@@ -174,7 +174,8 @@ Other matters
We have pretty much covered all the commands. There are few more but you
can figure them out yourselves. Just run `gcsms -h` to find out more.
-There are some caveats to gcsms:
+There are some caveats to using gcsms:
* Renaming a messaging list using `gcsms rename` only affects the name
in your list.
+* More to go here ...
View
39 gcsms.py
@@ -29,33 +29,6 @@
__maintainer__ = 'Mansour'
__version__ = '2.0'
-########################################################################
-# DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG DEBUG
-########################################################################
-
-import ssl
-realssl = ssl.SSLSocket
-
-class SSLSocketDebugger(realssl):
- def __init__(self, *args, **kwargs):
- realssl.__init__(self, *args, **kwargs)
-
- def send(self, *args, **kwargs):
- data = kwargs.get('data', None) or args[0]
- sys.stderr.write(data)
- return realssl.send(self, *args, **kwargs)
-
- def read(self, *args, **kwargs):
- data = realssl.read(self, *args, **kwargs)
- sys.stderr.write(data)
- return data
-
-#ssl.SSLSocket = SSLSocketDebugger #uncomment to see SSL traffic
-
-########################################################################
-# END OF DEBUG
-########################################################################
-
from datetime import datetime
import argparse
import json
@@ -106,15 +79,23 @@ def read(self, *args, **kwargs):
}
def _urlencval(val):
+ """URL encode a single value."""
return urlencode({'a': val})[2:]
def _url(urltype):
+ """Get the URL path of the type given."""
return _BASE_URL + _PATHS[urltype]
def _to_vid(mlid):
+ """Convert the messaging list ID to its visual representation."""
return ':' + mlid
def idname_arg(idname):
+ """Handle ID/NAME command line argument.
+
+ Return: tuple (type, value) where type in ['id', 'name']
+
+ """
if idname.startswith(':'):
if len(idname) < 2:
raise argparse.ArgumentTypeError(
@@ -124,12 +105,14 @@ def idname_arg(idname):
return ('name', idname)
def id_arg(s):
+ """Handle ID command line argument."""
if len(s) < 2 or not s.startswith(':'):
raise argparse.ArgumentTypeError(
"'%s' is not an id - must start with ':'" % s)
return s[1:]
def _ml_not_found(fn):
+ """Decorate to show a friendly message for 404 HTTP error."""
def wrapped_fn(*args, **kwargs):
try:
return fn(*args, **kwargs)
@@ -141,7 +124,7 @@ def wrapped_fn(*args, **kwargs):
return wrapped_fn
class Request(_Request):
- """Request with HTTP method as configurable property.
+ """Request with HTTP method as a configurable property.
From: http://stackoverflow.com/a/6312600/319954
Please sign in to comment.
Something went wrong with that request. Please try again.