(file, mode='r', *args, **kwargs)
| 186 | |
| 187 | @patch_func(builtins, 'open') |
| 188 | def open(file, mode='r', *args, **kwargs): |
| 189 | backend = get_file_backend(file) |
| 190 | if isinstance(backend, LocalBackend): |
| 191 | return open._fallback(file, mode, *args, **kwargs) |
| 192 | if 'b' in mode: |
| 193 | return io.BytesIO(backend.get(file, *args, **kwargs)) |
| 194 | else: |
| 195 | return io.StringIO(backend.get_text(file, *args, **kwargs)) |
| 196 | |
| 197 | if global_vars is not None and 'open' in global_vars: |
| 198 | bak_open = global_vars['open'] |