Python Forum
intercepting I/O - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: intercepting I/O (/thread-12969.html)



intercepting I/O - Skaperen - Sep-21-2018

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?