Python Forum

Full Version: intercepting I/O
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
a module (tarfile) will be doing lots of I/O including things like opening file, creating directories,symlinks, block devices, character devices, and so on. i want to be able to intercept all of its filesystem operations and handle them. and this is for not just the archive, which it lets you do through the archive open by passing it an object with read() or write() methods. consider extracting a tar archive. for each file in that archive it reads, it will open a file to write the data it reads for that file in the archive. i need to intercept all of that. what i am hoping for is a generalized means to do that in Python itself as opposed to lots of hooks coded in the module. anyone know of such a thing?