Contents
Pythonic filesystem abstractions: An overview of different filesystem(-like) APIs in Python and attempts for unifying them.
There's a lot of different filesystem(-like) APIs in Python. I intend to provide an overview of existing projects, their status and capabilities, and hopefully inspire you to work on improving things.
I intend to cover at least:
Spread all over the place, built-ins and miscellaneous stdlib
limited-purpose reimplementation of part of twisted.vfs
async doesn't look like sync
Deferred not going to stdlib?
Mock writing to /etc
See Petardfs for a generic FUSE fault injecting filesystem.
Not nice for unit tests, but maybe for system tests.
top = FilePath('toplevel')
sub = top.child('foo')
sub.createDirectory()
p = sub.child('bar')
with p.open('w') as f:
f.write('foo bar\n')
Invisible dotfiles
Virtual chroot
Custom ACL
f = self.fs.open("myfile")
implement needed part, KISS, croak on anything unwanted
wrap another implementation
p = self.fs.path("/my/safe/area")
p = p.child(user_input)
self.fs = NoDotfilesFS(self.fs)
self.fs = ChrootFS(
fs=self.fs,
root="/my/safe/area",
)
self.fs = AccessControlFS(
fs=self.fs,
acl=acl_rules,
)
path.py?
The path.py website at http://www.jorendorff.com/articles/python/path fails to load unless you do it on a full moon, in front of a mirror, and reload three times.
In the end, I don't think path.py is a suitable base for this:
It's probably a nice pragmatic helper, just not a good common API.
top = path('toplevel')
sub = top / 'foo'
sub.mkdir()
p = sub / 'bar'
with p.open('w') as f:
f.write('foo bar\n')
with self.fs.transact() as t:
t.path("foo").rename("foo.old")
with t.path("foo").open("w") as f:
f.write("bar\n")
Questions? Opinions? Rants?
Find me during the conference or sprints to talk more.
Slides etc up on eagain.net