PyFilesystem / pyfilesystem

Python filesystem abstraction layer
http://pyfilesystem.org/
BSD 3-Clause "New" or "Revised" License
286 stars 63 forks source link

MultiFS does not define getpathurl #192

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create MultiFS that contains two FTPFS at different paths

m = multifs.MultiFS()
pa = opener.opendir("ftp://ftp.a.net")
pb = opener.opendir("ftp://ftp.b.net")
m.addfs("a", pa)
m.addfs("b", pb)

2. Try getting the urlpath of something in a

p = m.geturlpath("file-on-a.txt")

(NoSuchMethodException)

What is the expected output? What do you see instead?

Expect the URL path for the requested path, retrieved from the FS that is 
returned by which(). Instead there's no implementation. 

What version of the product are you using? On what operating system?

$ python -V
Python 2.7.2
$ pip freeze | grep fs
fs==0.5.0
$ uname -a
Linux hostname 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 
x86_64 x86_64 x86_64 GNU/Linux

Please provide any additional information below.

Moneypatch I'm using for now:

def m_getpathurl(self, path, allow_none = False):
    """Monkeypatch MultiFS so it handles getpathurl (and haspathurl)"""
    return self.which(path)[1].getpathurl(path, allow_none) if ((not allow_none) or self.exists(path)) else None

import types
from fs import multifs

m = multifs.MultiFS()
m.getpathurl = types.MethodType(m_getpathurl, m)

Original issue reported on code.google.com by eluc...@gmail.com on 9 Dec 2014 at 8:48