aboutsummaryrefslogtreecommitdiff
path: root/apiclient
diff options
context:
space:
mode:
authorJoe Gregorio <jcgregorio@google.com>2012-12-10 10:22:37 -0500
committerJoe Gregorio <jcgregorio@google.com>2012-12-10 10:22:37 -0500
commit4772f3df368bd5f3d89cbab9728f9fd547e5b424 (patch)
tree43ff807b261f2dccbbec474f7a26549e5b25fbba /apiclient
parent504a17fa878cb57e89de73ebd48add7c67ee2ac5 (diff)
downloadgoogle-api-python-client-4772f3df368bd5f3d89cbab9728f9fd547e5b424.tar.gz
Allow deserialized discovery docs to be passed to build_from_document().
Reviewed in https://codereview.appspot.com/6906052/.
Diffstat (limited to 'apiclient')
-rw-r--r--apiclient/discovery.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/apiclient/discovery.py b/apiclient/discovery.py
index eb179ffe9..1fc33ca5a 100644
--- a/apiclient/discovery.py
+++ b/apiclient/discovery.py
@@ -225,7 +225,9 @@ def build_from_document(
document that is it given, as opposed to retrieving one over HTTP.
Args:
- service: string, discovery document.
+ service: string or object, the JSON discovery document describing the API.
+ The value passed in may either be the JSON string or the deserialized
+ JSON.
base: string, base URI for all HTTP requests, usually the discovery URI.
This parameter is no longer used as rootUrl and servicePath are included
within the discovery document. (deprecated)
@@ -245,7 +247,8 @@ def build_from_document(
# future is no longer used.
future = {}
- service = simplejson.loads(service)
+ if isinstance(service, basestring):
+ service = simplejson.loads(service)
base = urlparse.urljoin(service['rootUrl'], service['servicePath'])
schema = Schemas(service)