def unquote_v(self, nv): """ TODO: Do we need this? """ if len(nv) == 1: return nv else: return (nv[0], unquote(nv[1]))
def _canonical_query_string_url(self, parts): buf = "" if parts.query: qsa = parts.query.split("&") qsa = [a.split("=", 1) for a in qsa] quoted_qsa = [] for q in qsa: if len(q) == 2: quoted_qsa.append("%s=%s" % (quote(q[0], safe="-_.~"), quote(unquote(q[1]), safe="-_.~"))) elif len(q) == 1: quoted_qsa.append("%s=" % quote(q[0], safe="-_.~")) if len(quoted_qsa) > 0: quoted_qsa.sort(key=itemgetter(0)) buf += "&".join(quoted_qsa) return buf
def _canonical_query_string_url(self, parts): buf = '' if parts.query: qsa = parts.query.split('&') qsa = [a.split('=', 1) for a in qsa] quoted_qsa = [] for q in qsa: if len(q) == 2: quoted_qsa.append('%s=%s' % (quote( q[0], safe='-_.~'), quote(unquote(q[1]), safe='-_.~'))) elif len(q) == 1: quoted_qsa.append('%s=' % quote(q[0], safe='-_.~')) if len(quoted_qsa) > 0: quoted_qsa.sort() buf += '&'.join(quoted_qsa) return buf
def _canonical_query_string_url(self, parts): buf = '' if parts.query: qsa = parts.query.split('&') qsa = [a.split('=', 1) for a in qsa] quoted_qsa = [] for q in qsa: if len(q) == 2: quoted_qsa.append( '%s=%s' % (quote(q[0], safe='-_.~'), quote(unquote(q[1]), safe='-_.~'))) elif len(q) == 1: quoted_qsa.append('%s=' % quote(q[0], safe='-_.~')) if len(quoted_qsa) > 0: quoted_qsa.sort() buf += '&'.join(quoted_qsa) return buf
def canonical_query_string(self, request): split = urlsplit(request.url) buf = '' if split.query: qsa = split.query.split('&') qsa = [a.split('=', 1) for a in qsa] quoted_qsa = [] for q in qsa: if len(q) == 2: quoted_qsa.append( '%s=%s' % (quote(q[0], safe='-_.~'), quote(unquote(q[1]), safe='-_.~'))) elif len(q) == 1: quoted_qsa.append('%s=' % quote(q[0], safe='-_.~')) if len(quoted_qsa) > 0: quoted_qsa.sort(key=itemgetter(0)) buf += '&'.join(quoted_qsa) return buf
def copy_object(self, kwargs): """ This operation copies one s3 object to another location in s3. If either the bucket of the source or the destination does not exist, an error message will be sent stating that the bucket does not exist. """ bucket = kwargs['bucket'] key = kwargs['key'] copy_source = kwargs['copy_source'] src_bucket, src_key = find_bucket_key(copy_source) src_key = unquote(src_key) if hasattr(src_key, 'decode'): src_key = src_key.decode('utf-8') response_data = {} etag = '' if bucket in self.session.s3 or src_bucket in self.session.s3: src = self.session.s3[src_bucket][src_key] self.session.s3[bucket][key] = src else: response_data['Errors'] = [{'Message': 'Bucket does not exist'}] return FakeHttp(etag), response_data
def copy_object(self, kwargs): """ This operation copies one s3 object to another location in s3. If either the bucket of the source or the destination does not exist, an error message will be sent stating that the bucket does not exist. """ bucket = kwargs['bucket'] key = kwargs['key'] copy_source = kwargs['copy_source'] src_bucket, src_key = find_bucket_key(copy_source) src_key = unquote(src_key) if hasattr(src_key, 'decode'): src_key = src_key.decode('utf-8') response_data = {} etag = '' if bucket in self.session.s3 or src_bucket in self.session.s3: src = self.session.s3[src_bucket][src_key] self.session.s3[bucket][key] = src else: response_data['Errors'] = [{'Message': 'Bucket does not exist'}] response_data['ETag'] = '"%s"' % etag return FakeHttp(), response_data
def decode_quoted_jsondoc(value): try: value = json.loads(unquote(value)) except (ValueError, TypeError): logger.debug('Error loading quoted JSON', exc_info=True) return value
def decode_quoted_jsondoc(event_name, shape, value, **kwargs): try: value = json.loads(unquote(value)) except (ValueError, TypeError): logger.debug('Error loading quoted JSON', exc_info=True) return value