Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd041c88

Browse files
committed
documentation pass for generating sphinx docs
1 parent91a5d4a commitd041c88

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
importos
62
importhttplib2
73
fromurllibimporturlencode
@@ -32,15 +28,14 @@ def __init__(self, http_response, content):
3228

3329
classHTTPBackend(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
ifresource_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
defcontent_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
returnstr(len(body))ifbodyelse"0"
5955

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

6968
defencode(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
ifnotself.as_xml:
7577
returnjson.dumps(data)
@@ -78,7 +80,11 @@ def encode(self, data):
7880

7981
defdecode(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
ifnotself.as_xml:
8490
# only parse json when it exists, else just return None

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp