diaspora-event-sdk 0.2.6__py3-none-any.whl → 0.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ # Copyright (c) 2012-2013 Mitch Garnaat http://garnaat.org/
2
+ # Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
5
+ # may not use this file except in compliance with the License. A copy of
6
+ # the License is located at
7
+ #
8
+ # http://aws.amazon.com/apache2.0/
9
+ #
10
+ # or in the "license" file accompanying this file. This file is
11
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
+ # ANY KIND, either express or implied. See the License for the specific
13
+ # language governing permissions and limitations under the License.
14
+
15
+ def _exception_from_packed_args(exception_cls, args=None, kwargs=None):
16
+ # This is helpful for reducing Exceptions that only accept kwargs as
17
+ # only positional arguments can be provided for __reduce__
18
+ # Ideally, this would also be a class method on the BotoCoreError
19
+ # but instance methods cannot be pickled.
20
+ if args is None:
21
+ args = ()
22
+ if kwargs is None:
23
+ kwargs = {}
24
+ return exception_cls(*args, **kwargs)
25
+
26
+
27
+ class BotoCoreError(Exception):
28
+ """
29
+ The base exception class for BotoCore exceptions.
30
+
31
+ :ivar msg: The descriptive message associated with the error.
32
+ """
33
+
34
+ fmt = 'An unspecified error occurred'
35
+
36
+ def __init__(self, **kwargs):
37
+ msg = self.fmt.format(**kwargs)
38
+ Exception.__init__(self, msg)
39
+ self.kwargs = kwargs
40
+
41
+ def __reduce__(self):
42
+ return _exception_from_packed_args, (self.__class__, None, self.kwargs)
43
+
44
+
45
+ class NoCredentialsError(BotoCoreError):
46
+ """
47
+ No credentials could be found.
48
+ """
49
+
50
+ fmt = 'Unable to locate credentials'
51
+
52
+
53
+ class UnseekableStreamError(BotoCoreError):
54
+ """Need to seek a stream, but stream does not support seeking."""
55
+
56
+ fmt = (
57
+ 'Need to rewind the stream {stream_object}, but stream '
58
+ 'is not seekable.'
59
+ )
60
+
61
+
62
+ class MD5UnavailableError(BotoCoreError):
63
+ fmt = "This system does not support MD5 generation."
@@ -0,0 +1,174 @@
1
+ # Copyright 2012-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ import io
14
+ import logging
15
+ import re
16
+
17
+ from .compat import (
18
+ IPV6_ADDRZ_RE,
19
+ UNSAFE_URL_CHARS,
20
+ quote,
21
+ urlparse,
22
+ )
23
+
24
+ logger = logging.getLogger(__name__)
25
+ DEFAULT_METADATA_SERVICE_TIMEOUT = 1
26
+ METADATA_BASE_URL = 'http://169.254.169.254/'
27
+ METADATA_BASE_URL_IPv6 = 'http://[fd00:ec2::254]/'
28
+ METADATA_ENDPOINT_MODES = ('ipv4', 'ipv6')
29
+
30
+ # These are chars that do not need to be urlencoded.
31
+ # Based on rfc2986, section 2.3
32
+ SAFE_CHARS = '-._~'
33
+ LABEL_RE = re.compile(r'[a-z0-9][a-z0-9\-]*[a-z0-9]')
34
+ # RETRYABLE_HTTP_ERRORS = (
35
+ # ReadTimeoutError,
36
+ # EndpointConnectionError,
37
+ # ConnectionClosedError,
38
+ # ConnectTimeoutError,
39
+ # )
40
+ S3_ACCELERATE_WHITELIST = ['dualstack']
41
+
42
+ # This pattern can be used to detect if a header is a flexible checksum header
43
+ CHECKSUM_HEADER_PATTERN = re.compile(
44
+ r'^X-Amz-Checksum-([a-z0-9]*)$',
45
+ flags=re.IGNORECASE,
46
+ )
47
+
48
+
49
+ def determine_content_length(body):
50
+ # No body, content length of 0
51
+ if not body:
52
+ return 0
53
+
54
+ # Try asking the body for it's length
55
+ try:
56
+ return len(body)
57
+ except (AttributeError, TypeError):
58
+ pass
59
+
60
+ # Try getting the length from a seekable stream
61
+ if hasattr(body, 'seek') and hasattr(body, 'tell'):
62
+ try:
63
+ orig_pos = body.tell()
64
+ body.seek(0, 2)
65
+ end_file_pos = body.tell()
66
+ body.seek(orig_pos)
67
+ return end_file_pos - orig_pos
68
+ except io.UnsupportedOperation:
69
+ # in case when body is, for example, io.BufferedIOBase object
70
+ # it has "seek" method which throws "UnsupportedOperation"
71
+ # exception in such case we want to fall back to "chunked"
72
+ # encoding
73
+ pass
74
+ # Failed to determine the length
75
+ return None
76
+
77
+
78
+ def is_valid_ipv6_endpoint_url(endpoint_url):
79
+ if UNSAFE_URL_CHARS.intersection(endpoint_url):
80
+ return False
81
+ hostname = f'[{urlparse(endpoint_url).hostname}]'
82
+ return IPV6_ADDRZ_RE.match(hostname) is not None
83
+
84
+
85
+ def normalize_url_path(path):
86
+ if not path:
87
+ return '/'
88
+ return remove_dot_segments(path)
89
+
90
+
91
+ def remove_dot_segments(url):
92
+ # RFC 3986, section 5.2.4 "Remove Dot Segments"
93
+ # Also, AWS services require consecutive slashes to be removed,
94
+ # so that's done here as well
95
+ if not url:
96
+ return ''
97
+ input_url = url.split('/')
98
+ output_list = []
99
+ for x in input_url:
100
+ if x and x != '.':
101
+ if x == '..':
102
+ if output_list:
103
+ output_list.pop()
104
+ else:
105
+ output_list.append(x)
106
+
107
+ if url[0] == '/':
108
+ first = '/'
109
+ else:
110
+ first = ''
111
+ if url[-1] == '/' and output_list:
112
+ last = '/'
113
+ else:
114
+ last = ''
115
+ return first + '/'.join(output_list) + last
116
+
117
+
118
+ def percent_encode_sequence(mapping, safe=SAFE_CHARS):
119
+ """Urlencode a dict or list into a string.
120
+
121
+ This is similar to urllib.urlencode except that:
122
+
123
+ * It uses quote, and not quote_plus
124
+ * It has a default list of safe chars that don't need
125
+ to be encoded, which matches what AWS services expect.
126
+
127
+ If any value in the input ``mapping`` is a list type,
128
+ then each list element wil be serialized. This is the equivalent
129
+ to ``urlencode``'s ``doseq=True`` argument.
130
+
131
+ This function should be preferred over the stdlib
132
+ ``urlencode()`` function.
133
+
134
+ :param mapping: Either a dict to urlencode or a list of
135
+ ``(key, value)`` pairs.
136
+
137
+ """
138
+ encoded_pairs = []
139
+ if hasattr(mapping, 'items'):
140
+ pairs = mapping.items()
141
+ else:
142
+ pairs = mapping
143
+ for key, value in pairs:
144
+ if isinstance(value, list):
145
+ for element in value:
146
+ encoded_pairs.append(
147
+ f'{percent_encode(key)}={percent_encode(element)}'
148
+ )
149
+ else:
150
+ encoded_pairs.append(
151
+ f'{percent_encode(key)}={percent_encode(value)}'
152
+ )
153
+ return '&'.join(encoded_pairs)
154
+
155
+
156
+ def percent_encode(input_str, safe=SAFE_CHARS):
157
+ """Urlencodes a string.
158
+
159
+ Whereas percent_encode_sequence handles taking a dict/sequence and
160
+ producing a percent encoded string, this function deals only with
161
+ taking a string (not a dict/sequence) and percent encoding it.
162
+
163
+ If given the binary type, will simply URL encode it. If given the
164
+ text type, will produce the binary type by UTF-8 encoding the
165
+ text. If given something else, will convert it to the text type
166
+ first.
167
+ """
168
+ # If its not a binary or text string, make it a text string.
169
+ if not isinstance(input_str, (bytes, str)):
170
+ input_str = str(input_str)
171
+ # If it's not bytes, make it bytes by UTF-8 encoding it.
172
+ if not isinstance(input_str, bytes):
173
+ input_str = input_str.encode('utf-8')
174
+ return quote(input_str, safe=safe)
@@ -1 +1 @@
1
- __version__ = "0.2.6"
1
+ __version__ = "0.2.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diaspora-event-sdk
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: SDK of Diaspora Event Fabric: Resilience-enabling services for science from HPC to edge
5
5
  Home-page: https://github.com/globus-labs/diaspora-event-sdk
6
6
  License: Apache 2.0
@@ -1,5 +1,5 @@
1
1
  diaspora_event_sdk/__init__.py,sha256=v8IN3-WFpliakQKru8TAcmQ4IRdvRe_m9-abSDnGIFM,457
2
- diaspora_event_sdk/version.py,sha256=Oz5HbwHMyE87nmwV80AZzpkJPf-wBg7eDuJr_BXZkhU,22
2
+ diaspora_event_sdk/version.py,sha256=XHypfHSPdgXFKmOdoewn7czU670gt8InhHhzlP5j_aA,22
3
3
  diaspora_event_sdk/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  diaspora_event_sdk/sdk/_environments.py,sha256=QyQA7dV4goUKUoxAoaes8OGv0xKxz2qiFBHNGr-vQNA,204
5
5
  diaspora_event_sdk/sdk/aws_iam_msk.py,sha256=rT6RipRVt-Zf7pTsMf9UhH2HDNC0FW28LhciVH_45bc,3942
@@ -7,6 +7,13 @@ diaspora_event_sdk/sdk/client.py,sha256=fbjP_YRmGF2eItnMxNkdz5RIRvur0_P8DhE6AlYk
7
7
  diaspora_event_sdk/sdk/decorators.py,sha256=Gel8AyhIjbf4-FNintTNcOqvC9hHH_YwbOH257Nfmf0,884
8
8
  diaspora_event_sdk/sdk/kafka_client.py,sha256=xAxuPmMXIv0i_K_PFqc_BEG3wdGsFdYYvd7gUzeoLV8,4286
9
9
  diaspora_event_sdk/sdk/web_client.py,sha256=Rkp0ZUUXCeqbfVFUqX2oxvuLwqqW5_jsJJNN-v2L4FI,4770
10
+ diaspora_event_sdk/sdk/botocore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ diaspora_event_sdk/sdk/botocore/auth.py,sha256=QXwCNMzM0wAqD64RlFd-K27atRpixti73VKConpb1kk,18699
12
+ diaspora_event_sdk/sdk/botocore/awsrequest.py,sha256=fcR28YxbsCk2ZT1rGtgWxhje-sYt-SxIqixjOWAFLcM,9344
13
+ diaspora_event_sdk/sdk/botocore/compat.py,sha256=-vo-cE4aBRW3_U41_HqHCDiGwwFcGz5lFEB_eOMG73s,11055
14
+ diaspora_event_sdk/sdk/botocore/credentials.py,sha256=upSYlgIcp8piSFtGay4ryiCMqNJD5fWFq802p0DWIfI,2455
15
+ diaspora_event_sdk/sdk/botocore/exceptions.py,sha256=Wcu505IzZuyxOl4aE3iuXL-ByL6GDebWFrby7nACgqY,2002
16
+ diaspora_event_sdk/sdk/botocore/utils.py,sha256=TCSvM3QmwVFTDWmU55c1FtAZS0zMWjTkyywmaL1qfCk,5370
10
17
  diaspora_event_sdk/sdk/login_manager/__init__.py,sha256=yeqVgjeHLMX0WZJu2feJmq-fbeXvSxWghVV81ygfY-w,239
11
18
  diaspora_event_sdk/sdk/login_manager/client_login.py,sha256=8ild28_cgPSrLtg3Jhmzpg3EymAvH2UdAhKY52oOB_c,1835
12
19
  diaspora_event_sdk/sdk/login_manager/decorators.py,sha256=EFEp71d0oJ7vo2H8W7DJ2gPrDfGzeNXUNxri1C0l8h0,1047
@@ -19,8 +26,8 @@ diaspora_event_sdk/sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
19
26
  diaspora_event_sdk/sdk/utils/uuid_like.py,sha256=xbxf0YXpDhdii16lwPLWRN21qFekHrNrqODSToMPtCg,470
20
27
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
28
  tests/unit/test_client.py,sha256=sJUtPmnNGnohnP38RQrwcJ4D5j3-g1WFQ6gaKf520AQ,3019
22
- diaspora_event_sdk-0.2.6.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
23
- diaspora_event_sdk-0.2.6.dist-info/METADATA,sha256=2JJCyb4-F55L3mHG25HfgESP4OEgpTWuEs-UsRUxoOQ,2449
24
- diaspora_event_sdk-0.2.6.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
25
- diaspora_event_sdk-0.2.6.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
26
- diaspora_event_sdk-0.2.6.dist-info/RECORD,,
29
+ diaspora_event_sdk-0.2.7.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
30
+ diaspora_event_sdk-0.2.7.dist-info/METADATA,sha256=JO90S5bcI22dMxRmtI8iHmK6L4O9bwW32zJnUzAvCLw,2449
31
+ diaspora_event_sdk-0.2.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
32
+ diaspora_event_sdk-0.2.7.dist-info/top_level.txt,sha256=OVun-67t3fkLFEIwvJuNINgFFvAc--bClYhXjLhMmvs,25
33
+ diaspora_event_sdk-0.2.7.dist-info/RECORD,,