Oh, this looks really nice. Thank you for posting it!
A while back, I had an idea for modelling a filesystem as a dict, so maybe this will inspire me to get off my ass and actually write it.
Basically, the idea is that this:
foo = rootfs['home']['amyjess']['stuff']['foo.txt']
rootfs['home']['amyjess']['stuff']['bar.txt'] = bar
would be equivalent to this:
with open('/home/amyjess/stuff/foo.txt', 'r') as foo_file:
foo = foo_file.read()
with open('/home/amyjess/stuff/bar.txt', 'w') as bar_file:
bar_file.write(bar)
It's funny you mention that, I have literally that functionality in my "blob storage" python wrapper. Currently it's just like 50 lines of code I use for internal ad-hoc storage because as it turns out, reasoning about storage as a hierarchy is really nice. (I also let you index with a list, where the list is the hierarchical path; the key part being composibility, which I imagine you can do reasonably with both models).
Interesting to know that it's a more common pattern. I will have to think a bit on where that may go. I had always shot down any "value" with "it's just a thin transformation on top of path.join". (yay self-deprecation or something?)
I once made something like this to mount json files as a fuse filesystem. It's not maintained and one of my first projects, so the code is somewhat questionable, but it does work.
It basically mounts a dict on a filesystem, the exact opposite of what you want :)
Well, mostly because I wanted to play with fuse, but it started out as an ansible thing (doesn't work with >2 though).
The ansible setup module returns the system information in json, and if you mount it with the --realtime flag, when you open a "file" like ram for instance, ansible fetches the current value for you. That way you have your infrastructure mounted so to speak. Sort of a /proc filesystem for your linux infrastructure.
I never got further than a working poc though. It works, but there are some bugs and there is no regard for security.
You might want to look at how Common Lisp abstracted the filesystem 20-odd years ago as an example of how to do it right and also how to do it wrong (e.g. lack of iterators in those days)
Maybe have a proxy https://pypi.python.org/pypi/pyfilesystem that has `fs` as a requirement? That way even if people install with `pip install pyfilesystem`, you're good.
As long as you can recursively process folders and files without stopping early due to an UnauthorizedAccessException-equivalent (which .NET didn't straighten out 'til v4).
A while back, I had an idea for modelling a filesystem as a dict, so maybe this will inspire me to get off my ass and actually write it.
Basically, the idea is that this:
would be equivalent to this: I really want to implement that now.