Total Complexity | 4 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 64.29% |
Changes | 0 |
1 | """ |
||
2 | Code used under MIT License from https://www.backblaze.com/b2/docs/string_encoding.html |
||
3 | |||
4 | Copyright (c) 2015 Backblaze |
||
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
||
|
|||
6 | |||
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
||
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
9 | |||
10 | Additional code copyright George Sibble 2018 |
||
11 | """ |
||
12 | |||
13 | 1 | try: |
|
14 | 1 | from urllib import quote, unquote_plus |
|
15 | except ImportError: |
||
16 | from urllib.parse import quote, unquote_plus |
||
17 | |||
18 | |||
19 | 1 | def b2_url_encode(s): |
|
20 | 1 | return quote(s.encode('utf-8')) |
|
21 | |||
22 | |||
23 | 1 | def b2_url_decode(s): |
|
24 | return unquote_plus(str(s)).decode('utf-8') |
||
25 | |||
26 | |||
27 | 1 | def decode_error(response): |
|
28 | 1 | try: |
|
29 | 1 | response_json = response.json() |
|
30 | 1 | return str(response.status_code) + ' - ' + str(response_json) |
|
31 | except ValueError: |
||
32 | raise ValueError(str(response.status_code) + ' - Invalid JSON Response') |
||
33 |
This check looks for lines that are too long. You can specify the maximum line length.