| Index: appengine/chromium_build_logs/third_party/googleapiclient/schema.py
|
| diff --git a/appengine/chromium_build_logs/third_party/apiclient/schema.py b/appengine/chromium_build_logs/third_party/googleapiclient/schema.py
|
| similarity index 92%
|
| rename from appengine/chromium_build_logs/third_party/apiclient/schema.py
|
| rename to appengine/chromium_build_logs/third_party/googleapiclient/schema.py
|
| index ddcd670df207f9654489b7c28f33a13f24e1a694..ecb3f8bf19cc9443773d482e940b5923b0fc2006 100644
|
| --- a/appengine/chromium_build_logs/third_party/apiclient/schema.py
|
| +++ b/appengine/chromium_build_logs/third_party/googleapiclient/schema.py
|
| @@ -1,4 +1,4 @@
|
| -# Copyright (C) 2010 Google Inc.
|
| +# Copyright 2014 Google Inc. All Rights Reserved.
|
| #
|
| # Licensed under the Apache License, Version 2.0 (the "License");
|
| # you may not use this file except in compliance with the License.
|
| @@ -56,13 +56,16 @@ For example, given the schema:
|
|
|
| The constructor takes a discovery document in which to look up named schema.
|
| """
|
| +from __future__ import absolute_import
|
| +import six
|
|
|
| # TODO(jcgregorio) support format, enum, minimum, maximum
|
|
|
| __author__ = 'jcgregorio@google.com (Joe Gregorio)'
|
|
|
| import copy
|
| -from oauth2client.anyjson import simplejson
|
| +
|
| +from oauth2client import util
|
|
|
|
|
| class Schemas(object):
|
| @@ -80,6 +83,7 @@ class Schemas(object):
|
| # Cache of pretty printed schemas.
|
| self.pretty = {}
|
|
|
| + @util.positional(2)
|
| def _prettyPrintByName(self, name, seen=None, dent=0):
|
| """Get pretty printed object prototype from the schema name.
|
|
|
| @@ -102,7 +106,7 @@ class Schemas(object):
|
|
|
| if name not in self.pretty:
|
| self.pretty[name] = _SchemaToStruct(self.schemas[name],
|
| - seen, dent).to_str(self._prettyPrintByName)
|
| + seen, dent=dent).to_str(self._prettyPrintByName)
|
|
|
| seen.pop()
|
|
|
| @@ -121,6 +125,7 @@ class Schemas(object):
|
| # Return with trailing comma and newline removed.
|
| return self._prettyPrintByName(name, seen=[], dent=1)[:-2]
|
|
|
| + @util.positional(2)
|
| def _prettyPrintSchema(self, schema, seen=None, dent=0):
|
| """Get pretty printed object prototype of schema.
|
|
|
| @@ -136,7 +141,7 @@ class Schemas(object):
|
| if seen is None:
|
| seen = []
|
|
|
| - return _SchemaToStruct(schema, seen, dent).to_str(self._prettyPrintByName)
|
| + return _SchemaToStruct(schema, seen, dent=dent).to_str(self._prettyPrintByName)
|
|
|
| def prettyPrintSchema(self, schema):
|
| """Get pretty printed object prototype of schema.
|
| @@ -163,6 +168,7 @@ class Schemas(object):
|
| class _SchemaToStruct(object):
|
| """Convert schema to a prototype object."""
|
|
|
| + @util.positional(3)
|
| def __init__(self, schema, seen, dent=0):
|
| """Constructor.
|
|
|
| @@ -244,15 +250,19 @@ class _SchemaToStruct(object):
|
| if stype == 'object':
|
| self.emitEnd('{', schema.get('description', ''))
|
| self.indent()
|
| - for pname, pschema in schema.get('properties', {}).iteritems():
|
| - self.emitBegin('"%s": ' % pname)
|
| - self._to_str_impl(pschema)
|
| + if 'properties' in schema:
|
| + for pname, pschema in six.iteritems(schema.get('properties', {})):
|
| + self.emitBegin('"%s": ' % pname)
|
| + self._to_str_impl(pschema)
|
| + elif 'additionalProperties' in schema:
|
| + self.emitBegin('"a_key": ')
|
| + self._to_str_impl(schema['additionalProperties'])
|
| self.undent()
|
| self.emit('},')
|
| elif '$ref' in schema:
|
| schemaName = schema['$ref']
|
| description = schema.get('description', '')
|
| - s = self.from_cache(schemaName, self.seen)
|
| + s = self.from_cache(schemaName, seen=self.seen)
|
| parts = s.splitlines()
|
| self.emitEnd(parts[0], description)
|
| for line in parts[1:]:
|
|
|