Live data from Hacker News

Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

willmcgugan.com

1–10 of 22 posts

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#2
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)
I really want to implement that now.

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#3
post #2

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…

Nice idea!

You can also do this with PyFilesystem...

    fs.gettext('/home/amyjess/stuff/foo.txt')
    fs.settext('/home/amyjess/stuff/foo.txt', bar)
There are equivalent bytes methods.

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#4
pyfilesystem is great!

My only suggestion would be to improve the search optimization for pypi.

It's the ~10th result for https://pypi.python.org/pypi?%3Aaction=search&term=pyfilesys... and a page down on https://pypi.python.org/pypi?%3Aaction=search&term=fs&submit...

It's really not clear what it's called since the package name is 'fs' but the project is 'pyfilesystem'.

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#5
post #2

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…

You might want to look at pathlib:

    with (Path.home() / '.config' / '1234.conf').open() as fd:
        print('Hello', file=fd)
Granted, with / precedence you'll often need parens to group / before .

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#6
post #2

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…

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?)

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#7
post #2

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…

There is already pathlib in Python's stdlib that do something similar:

>>> p = PurePath('/etc') >>> p PurePosixPath('/etc') >>> p / 'init.d' / 'apache2' PurePosixPath('/etc/init.d/apache2')

And yeah, this uses operator overload. However it does look quite nice.

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#8
post #4

pyfilesystem is great! My only suggestion would be to improve the search optimization for pypi. It's the ~10th result for https://pypi.python.org/pypi?%3Aaction=search&term=pyfilesys... and a page down on https://pypi.python.org/pypi?%3Aaction=search&term=fs&submit... It's really not clear what it's called since the package name is 'fs' but the project is 'pyfilesystem'.

> pyfilesystem is great!

Cheers.

> My only suggestion would be to improve the search optimization for pypi.

Fair point. Not entirely sure how to fix that. I'll look in to it...

Re: Show HN: PyFilesystem 2.0 – A Python interface to filesystems of all kinds

#9
post #4

pyfilesystem is great! My only suggestion would be to improve the search optimization for pypi. It's the ~10th result for https://pypi.python.org/pypi?%3Aaction=search&term=pyfilesys... and a page down on https://pypi.python.org/pypi?%3Aaction=search&term=fs&submit... It's really not clear what it's called since the package name is 'fs' but the project is 'pyfilesystem'.

> pyfilesystem is great! Cheers. > My only suggestion would be to improve the search optimization for pypi. Fair point. Not entirely sure how to fix that. I'll look in to it...

PKG-INFO, line 2:

Name: fs

Looks like it's also registered in PyPI as "fs", from the URL: https://pypi.python.org/pypi/fs/

Post reply on HN