(endpoint)
| 22 | |
| 23 | |
| 24 | def fetch_dict(endpoint): |
| 25 | data = None |
| 26 | if endpoint.startswith(('http:', 'https:', 'ftp:')): |
| 27 | proxies = autodetect_proxy() |
| 28 | |
| 29 | if proxies: |
| 30 | response = requests.get(url=endpoint, proxies=proxies) |
| 31 | else: |
| 32 | response = requests.get(url=endpoint) |
| 33 | |
| 34 | try: |
| 35 | data = response.json() |
| 36 | except json.decoder.JSONDecodeError: |
| 37 | data = {} |
| 38 | else: |
| 39 | data = {} |
| 40 | if os.path.exists(endpoint): |
| 41 | with open(endpoint) as fd: |
| 42 | try: |
| 43 | data = json.load(fd) |
| 44 | except json.JSONDecodeError: |
| 45 | data = {} |
| 46 | |
| 47 | return data |
| 48 | |
| 49 | |
| 50 | def create_default_json_msg(): |
no test coverage detected