Builds a query string. Args: params: dict, the query parameters Returns: The query parameters properly encoded into an HTTP URI query string.
(self, params)
| 182 | return (headers, path_params, query, body_value) |
| 183 | |
| 184 | def _build_query(self, params): |
| 185 | """Builds a query string. |
| 186 | |
| 187 | Args: |
| 188 | params: dict, the query parameters |
| 189 | |
| 190 | Returns: |
| 191 | The query parameters properly encoded into an HTTP URI query string. |
| 192 | """ |
| 193 | if self.alt_param is not None: |
| 194 | params.update({"alt": self.alt_param}) |
| 195 | astuples = [] |
| 196 | for key, value in params.items(): |
| 197 | if type(value) == type([]): |
| 198 | for x in value: |
| 199 | x = x.encode("utf-8") |
| 200 | astuples.append((key, x)) |
| 201 | else: |
| 202 | if isinstance(value, str) and callable(value.encode): |
| 203 | value = value.encode("utf-8") |
| 204 | astuples.append((key, value)) |
| 205 | return "?" + urllib.parse.urlencode(astuples) |
| 206 | |
| 207 | def _log_response(self, resp, content): |
| 208 | """Logs debugging information about the response if requested.""" |