(prefix, path, mode)
| 84 | |
| 85 | |
| 86 | def get_file(prefix, path, mode): |
| 87 | file_path = os.path.expandvars(os.path.expanduser(path[len(prefix) :])) |
| 88 | try: |
| 89 | with compat_open(file_path, mode) as f: |
| 90 | return f.read() |
| 91 | except UnicodeDecodeError: |
| 92 | raise ResourceLoadingError( |
| 93 | 'Unable to load paramfile (%s), text contents could ' |
| 94 | 'not be decoded. If this is a binary file, please use the ' |
| 95 | 'fileb:// prefix instead of the file:// prefix.' % file_path |
| 96 | ) |
| 97 | except OSError as e: |
| 98 | raise ResourceLoadingError( |
| 99 | 'Unable to load paramfile %s: %s' % (path, e) |
| 100 | ) |
| 101 | |
| 102 | |
| 103 | LOCAL_PREFIX_MAP = { |
nothing calls this directly
no test coverage detected