(fname)
| 862 | |
| 863 | @contextlib.contextmanager |
| 864 | def _open_file_or_url(fname): |
| 865 | if (isinstance(fname, str) |
| 866 | and fname.startswith(('http://', 'https://', 'ftp://', 'file:'))): |
| 867 | import urllib.request |
| 868 | ssl_ctx = _get_ssl_context() |
| 869 | if ssl_ctx is None: |
| 870 | _log.debug( |
| 871 | "Could not get certifi ssl context, https may not work." |
| 872 | ) |
| 873 | with urllib.request.urlopen(fname, context=ssl_ctx) as f: |
| 874 | yield (line.decode('utf-8') for line in f) |
| 875 | else: |
| 876 | fname = os.path.expanduser(fname) |
| 877 | with open(fname, encoding='utf-8') as f: |
| 878 | yield f |
| 879 | |
| 880 | |
| 881 | def _rc_params_in_file(fname, transform=lambda x: x, fail_on_error=False): |
no test coverage detected
searching dependent graphs…