Craig Citro | 751b7fb | 2014-09-23 11:20:38 -0700 | [diff] [blame] | 1 | # Copyright 2014 Google Inc. All Rights Reserved. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | """Schema processing for discovery based APIs |
| 16 | |
| 17 | Schemas holds an APIs discovery schemas. It can return those schema as |
| 18 | deserialized JSON objects, or pretty print them as prototype objects that |
| 19 | conform to the schema. |
| 20 | |
| 21 | For example, given the schema: |
| 22 | |
| 23 | schema = \"\"\"{ |
| 24 | "Foo": { |
| 25 | "type": "object", |
| 26 | "properties": { |
| 27 | "etag": { |
| 28 | "type": "string", |
| 29 | "description": "ETag of the collection." |
| 30 | }, |
| 31 | "kind": { |
| 32 | "type": "string", |
| 33 | "description": "Type of the collection ('calendar#acl').", |
| 34 | "default": "calendar#acl" |
| 35 | }, |
| 36 | "nextPageToken": { |
| 37 | "type": "string", |
| 38 | "description": "Token used to access the next |
| 39 | page of this result. Omitted if no further results are available." |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | }\"\"\" |
| 44 | |
| 45 | s = Schemas(schema) |
| 46 | print s.prettyPrintByName('Foo') |
| 47 | |
| 48 | Produces the following output: |
| 49 | |
| 50 | { |
| 51 | "nextPageToken": "A String", # Token used to access the |
| 52 | # next page of this result. Omitted if no further results are available. |
| 53 | "kind": "A String", # Type of the collection ('calendar#acl'). |
| 54 | "etag": "A String", # ETag of the collection. |
| 55 | }, |
| 56 | |
| 57 | The constructor takes a discovery document in which to look up named schema. |
| 58 | """ |
INADA Naoki | e4ea1a9 | 2015-03-04 03:45:42 +0900 | [diff] [blame] | 59 | from __future__ import absolute_import |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 60 | |
| 61 | # TODO(jcgregorio) support format, enum, minimum, maximum |
| 62 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 63 | __author__ = "jcgregorio@google.com (Joe Gregorio)" |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 64 | |
Joe Gregorio | 68a8cfe | 2012-08-03 16:17:40 -0400 | [diff] [blame] | 65 | |
Anthonios Partheniou | b1b0c83 | 2020-12-14 14:24:19 -0500 | [diff] [blame] | 66 | from collections import OrderedDict |
Helen Koike | de13e3b | 2018-04-26 16:05:16 -0300 | [diff] [blame] | 67 | from googleapiclient import _helpers as util |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 68 | |
| 69 | |
| 70 | class Schemas(object): |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 71 | """Schemas for an API.""" |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 72 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 73 | def __init__(self, discovery): |
| 74 | """Constructor. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 75 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 76 | Args: |
| 77 | discovery: object, Deserialized discovery document from which we pull |
| 78 | out the named schema. |
| 79 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 80 | self.schemas = discovery.get("schemas", {}) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 81 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 82 | # Cache of pretty printed schemas. |
| 83 | self.pretty = {} |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 84 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 85 | @util.positional(2) |
| 86 | def _prettyPrintByName(self, name, seen=None, dent=0): |
| 87 | """Get pretty printed object prototype from the schema name. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 88 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 89 | Args: |
| 90 | name: string, Name of schema in the discovery document. |
| 91 | seen: list of string, Names of schema already seen. Used to handle |
| 92 | recursive definitions. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 93 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 94 | Returns: |
| 95 | string, A string that contains a prototype object with |
| 96 | comments that conforms to the given schema. |
| 97 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 98 | if seen is None: |
| 99 | seen = [] |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 100 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 101 | if name in seen: |
| 102 | # Do not fall into an infinite loop over recursive definitions. |
| 103 | return "# Object with schema name: %s" % name |
| 104 | seen.append(name) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 105 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 106 | if name not in self.pretty: |
| 107 | self.pretty[name] = _SchemaToStruct( |
| 108 | self.schemas[name], seen, dent=dent |
| 109 | ).to_str(self._prettyPrintByName) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 110 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 111 | seen.pop() |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 112 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 113 | return self.pretty[name] |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 114 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 115 | def prettyPrintByName(self, name): |
| 116 | """Get pretty printed object prototype from the schema name. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 117 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 118 | Args: |
| 119 | name: string, Name of schema in the discovery document. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 120 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 121 | Returns: |
| 122 | string, A string that contains a prototype object with |
| 123 | comments that conforms to the given schema. |
| 124 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 125 | # Return with trailing comma and newline removed. |
Anthonios Partheniou | b1b0c83 | 2020-12-14 14:24:19 -0500 | [diff] [blame] | 126 | return self._prettyPrintByName(name, seen=[], dent=0)[:-2] |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 127 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 128 | @util.positional(2) |
| 129 | def _prettyPrintSchema(self, schema, seen=None, dent=0): |
| 130 | """Get pretty printed object prototype of schema. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 131 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 132 | Args: |
| 133 | schema: object, Parsed JSON schema. |
| 134 | seen: list of string, Names of schema already seen. Used to handle |
| 135 | recursive definitions. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 136 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 137 | Returns: |
| 138 | string, A string that contains a prototype object with |
| 139 | comments that conforms to the given schema. |
| 140 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 141 | if seen is None: |
| 142 | seen = [] |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 143 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 144 | return _SchemaToStruct(schema, seen, dent=dent).to_str(self._prettyPrintByName) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 145 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 146 | def prettyPrintSchema(self, schema): |
| 147 | """Get pretty printed object prototype of schema. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 148 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 149 | Args: |
| 150 | schema: object, Parsed JSON schema. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 151 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 152 | Returns: |
| 153 | string, A string that contains a prototype object with |
| 154 | comments that conforms to the given schema. |
| 155 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 156 | # Return with trailing comma and newline removed. |
Anthonios Partheniou | b1b0c83 | 2020-12-14 14:24:19 -0500 | [diff] [blame] | 157 | return self._prettyPrintSchema(schema, dent=0)[:-2] |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 158 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 159 | def get(self, name, default=None): |
| 160 | """Get deserialized JSON schema from the schema name. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 161 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 162 | Args: |
| 163 | name: string, Schema name. |
| 164 | default: object, return value if name not found. |
| 165 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 166 | return self.schemas.get(name, default) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 167 | |
| 168 | |
| 169 | class _SchemaToStruct(object): |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 170 | """Convert schema to a prototype object.""" |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 171 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 172 | @util.positional(3) |
| 173 | def __init__(self, schema, seen, dent=0): |
| 174 | """Constructor. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 175 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 176 | Args: |
| 177 | schema: object, Parsed JSON schema. |
| 178 | seen: list, List of names of schema already seen while parsing. Used to |
| 179 | handle recursive definitions. |
| 180 | dent: int, Initial indentation depth. |
| 181 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 182 | # The result of this parsing kept as list of strings. |
| 183 | self.value = [] |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 184 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 185 | # The final value of the parsing. |
| 186 | self.string = None |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 187 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 188 | # The parsed JSON schema. |
| 189 | self.schema = schema |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 190 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 191 | # Indentation level. |
| 192 | self.dent = dent |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 193 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 194 | # Method that when called returns a prototype object for the schema with |
| 195 | # the given name. |
| 196 | self.from_cache = None |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 197 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 198 | # List of names of schema already seen while parsing. |
| 199 | self.seen = seen |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 200 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 201 | def emit(self, text): |
| 202 | """Add text as a line to the output. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 203 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 204 | Args: |
| 205 | text: string, Text to output. |
| 206 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 207 | self.value.extend([" " * self.dent, text, "\n"]) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 208 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 209 | def emitBegin(self, text): |
| 210 | """Add text to the output, but with no line terminator. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 211 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 212 | Args: |
| 213 | text: string, Text to output. |
| 214 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 215 | self.value.extend([" " * self.dent, text]) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 216 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 217 | def emitEnd(self, text, comment): |
| 218 | """Add text and comment to the output with line terminator. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 219 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 220 | Args: |
| 221 | text: string, Text to output. |
| 222 | comment: string, Python comment. |
| 223 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 224 | if comment: |
| 225 | divider = "\n" + " " * (self.dent + 2) + "# " |
| 226 | lines = comment.splitlines() |
| 227 | lines = [x.rstrip() for x in lines] |
| 228 | comment = divider.join(lines) |
| 229 | self.value.extend([text, " # ", comment, "\n"]) |
| 230 | else: |
| 231 | self.value.extend([text, "\n"]) |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 232 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 233 | def indent(self): |
| 234 | """Increase indentation level.""" |
| 235 | self.dent += 1 |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 236 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 237 | def undent(self): |
| 238 | """Decrease indentation level.""" |
| 239 | self.dent -= 1 |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 240 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 241 | def _to_str_impl(self, schema): |
| 242 | """Prototype object based on the schema, in Python code with comments. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 243 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 244 | Args: |
| 245 | schema: object, Parsed JSON schema file. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 246 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 247 | Returns: |
| 248 | Prototype object based on the schema, in Python code with comments. |
| 249 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 250 | stype = schema.get("type") |
| 251 | if stype == "object": |
| 252 | self.emitEnd("{", schema.get("description", "")) |
| 253 | self.indent() |
| 254 | if "properties" in schema: |
Anthonios Partheniou | b1b0c83 | 2020-12-14 14:24:19 -0500 | [diff] [blame] | 255 | properties = schema.get("properties", {}) |
| 256 | sorted_properties = OrderedDict(sorted(properties.items())) |
Anthonios Partheniou | 9f7b410 | 2021-07-23 12:18:25 -0400 | [diff] [blame] | 257 | for pname, pschema in sorted_properties.items(): |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 258 | self.emitBegin('"%s": ' % pname) |
| 259 | self._to_str_impl(pschema) |
| 260 | elif "additionalProperties" in schema: |
| 261 | self.emitBegin('"a_key": ') |
| 262 | self._to_str_impl(schema["additionalProperties"]) |
| 263 | self.undent() |
| 264 | self.emit("},") |
| 265 | elif "$ref" in schema: |
| 266 | schemaName = schema["$ref"] |
| 267 | description = schema.get("description", "") |
| 268 | s = self.from_cache(schemaName, seen=self.seen) |
| 269 | parts = s.splitlines() |
| 270 | self.emitEnd(parts[0], description) |
| 271 | for line in parts[1:]: |
| 272 | self.emit(line.rstrip()) |
| 273 | elif stype == "boolean": |
| 274 | value = schema.get("default", "True or False") |
| 275 | self.emitEnd("%s," % str(value), schema.get("description", "")) |
| 276 | elif stype == "string": |
| 277 | value = schema.get("default", "A String") |
| 278 | self.emitEnd('"%s",' % str(value), schema.get("description", "")) |
| 279 | elif stype == "integer": |
| 280 | value = schema.get("default", "42") |
| 281 | self.emitEnd("%s," % str(value), schema.get("description", "")) |
| 282 | elif stype == "number": |
| 283 | value = schema.get("default", "3.14") |
| 284 | self.emitEnd("%s," % str(value), schema.get("description", "")) |
| 285 | elif stype == "null": |
| 286 | self.emitEnd("None,", schema.get("description", "")) |
| 287 | elif stype == "any": |
| 288 | self.emitEnd('"",', schema.get("description", "")) |
| 289 | elif stype == "array": |
| 290 | self.emitEnd("[", schema.get("description")) |
| 291 | self.indent() |
| 292 | self.emitBegin("") |
| 293 | self._to_str_impl(schema["items"]) |
| 294 | self.undent() |
| 295 | self.emit("],") |
| 296 | else: |
| 297 | self.emit("Unknown type! %s" % stype) |
| 298 | self.emitEnd("", "") |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 299 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 300 | self.string = "".join(self.value) |
| 301 | return self.string |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 302 | |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 303 | def to_str(self, from_cache): |
| 304 | """Prototype object based on the schema, in Python code with comments. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 305 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 306 | Args: |
| 307 | from_cache: callable(name, seen), Callable that retrieves an object |
| 308 | prototype for a schema with the given name. Seen is a list of schema |
| 309 | names already seen as we recursively descend the schema definition. |
Joe Gregorio | 2b78128 | 2011-12-08 12:00:25 -0500 | [diff] [blame] | 310 | |
arfy slowy | d35c912 | 2021-07-15 00:16:31 +0700 | [diff] [blame] | 311 | Returns: |
| 312 | Prototype object based on the schema, in Python code with comments. |
| 313 | The lines of the code will all be properly indented. |
| 314 | """ |
Bu Sun Kim | 66bb32c | 2019-10-30 10:11:58 -0700 | [diff] [blame] | 315 | self.from_cache = from_cache |
| 316 | return self._to_str_impl(self.schema) |