Skip to content

Commit d041c88

Browse files
committed
documentation pass for generating sphinx docs
1 parent 91a5d4a commit d041c88

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

zencoder/core.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
"""
2-
Main Zencoder module
3-
"""
4-
51
import os
62
import httplib2
73
from urllib import urlencode
@@ -32,15 +28,14 @@ def __init__(self, http_response, content):
3228

3329
class HTTPBackend(object):
3430
"""
35-
Abstracts out an HTTP backend, but defaults to httplib2
31+
Abstracts out an HTTP backend, but defaults to httplib2. Required arguments
32+
are `base_url` and `api_key`.
3633
37-
@FIXME: Build in support for supplying arbitrary backends
34+
.. note::
35+
While `as_xml` is provided as a keyword argument, XML or input or output
36+
is not supported.
3837
"""
3938
def __init__(self, base_url, api_key, as_xml=False, resource_name=None, timeout=None, test=False, version=None):
40-
"""
41-
Creates an HTTPBackend object, which abstracts out some of the
42-
library specific HTTP stuff.
43-
"""
4439
self.base_url = base_url
4540
if resource_name:
4641
self.base_url = self.base_url + resource_name
@@ -53,12 +48,16 @@ def __init__(self, base_url, api_key, as_xml=False, resource_name=None, timeout=
5348

5449
def content_length(self, body):
5550
"""
56-
Returns the content length as an int for the given body data
51+
Returns the content length as an int for the given `body` data. Used by
52+
PUT and POST requests to set the Content-Length header.
5753
"""
5854
return str(len(body)) if body else "0"
5955

6056
@property
6157
def headers(self):
58+
""" Returns default headers, by setting the Content-Type and Accepts
59+
headers.
60+
"""
6261
if self.as_xml:
6362
return {'Content-Type': 'application/xml',
6463
'Accepts': 'application/xml'}
@@ -68,8 +67,11 @@ def headers(self):
6867

6968
def encode(self, data):
7069
"""
71-
Encodes data as either JSON or XML, so that it can be passed onto
72-
the Zencoder API
70+
Encodes data as JSON (by calling `json.dumps`), so that it can be
71+
passed onto the Zencoder API.
72+
73+
.. note::
74+
Encoding as XML is not supported.
7375
"""
7476
if not self.as_xml:
7577
return json.dumps(data)
@@ -78,7 +80,11 @@ def encode(self, data):
7880

7981
def decode(self, raw_body):
8082
"""
81-
Returns the raw_body as json (the default) or XML
83+
Returns the JSON-encoded `raw_body` and decodes it to a `dict` (using
84+
`json.loads`).
85+
86+
.. note::
87+
Decoding as XML is not supported.
8288
"""
8389
if not self.as_xml:
8490
# only parse json when it exists, else just return None

0 commit comments

Comments
 (0)