Repository navigation
patch Python builtins with PyFilesystem - #155
willmcgugan wants to merge 6 commits into
Conversation
|
No but seriously, this looks great, both for compatibility and usability purposes. (you may not be able to get On later Python versions, you may be interested in patching |
|
I'm not the best of wizards. This magic isn't easy. If you patch module naively with something like this: It appears to work for the most part. But! If a module imports thusly: The I found a solution to this. You can replace the And then all references to It was starting to look like my this magic would not work as well as I'd hoped. But then I recalled that I could use the If you call this: It returned a list objects that contain a reference to the Naturally its not trivial. It's not enough to replace the So I need to replace any keys where And that seems to work. Although it does require the use of Because of this dark magic, I think I'm going to make it an external project. And make it Python3 only. Python2 compatibility would literally double the work. Will close this PR shortly. @althonos Don't know if you have any experience monkey patching? Wouldn't want to carry on this way only to find out there is a much simpler solution. |
|
Impressive work (even if that did not turn as expected)! I'm not the best when it comes to the interpreter internals, so I cannot really help here. I quickly tested if the |

Work in Progress
Will add a new feature to PyFilesystem, where a filesystem may be patched over the Python builtins. Here's an example of how it will work:
Here
os.listdirandopenwill use the s3 filesystem. So PyFilesystem can work with any code not explicitly written with the PyFIlesystem API.@althonos early days on this one. Feedback welcome.