flying-circus / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

MultiOpener doesn't has ability to set writefs [patch] #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
To create writable milti://... filesystems, the following patch should be 
applied to fs/opener.py:

     @classmethod
     def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir):

         from fs.multifs import MultiFS
         from ConfigParser import ConfigParser
         cfg = ConfigParser()

         if '#' in fs_path:
             path, section = fs_path.split('#', 1) 
         else:
             path = fs_path
             section = 'fs'

         cfg.readfp(registry.open(path))

         multi_fs = MultiFS()
         for name, fs_url in cfg.items(section):                                  
-            multi_fs.addfs(name, registry.opendir(fs_url, 
create_dir=create_dir))
+            multi_fs.addfs(name, registry.opendir(fs_url, 
create_dir=create_dir), name=='writefs')
         return multi_fs, ''

Original issue reported on code.google.com by dubn...@gmail.com on 4 May 2012 at 9:53

GoogleCodeExporter commented 9 years ago
I'm -1 on the suggested patch. MultiFS can only have one writefs, so your patch 
would be constantly switching the writefs to the last-added FS. And maybe you 
don't even want a writefs?! Or maybe you simply don't want to have the writefs 
as the very last line of the ini file.

IMHO a better solution would be to add some kind of extra (optional) syntax to 
the end of the FS URL that you want to be the writefs in the ini file used by 
MultiOpener (I'm not familiar enough with fs.opener to suggest what the syntax 
might be) and then have MultiOpener raise an exception if there's more than one 
writefs specified in the ini file.

Original comment by gc...@loowis.durge.org on 16 Aug 2012 at 9:04

GoogleCodeExporter commented 9 years ago
I concur. I agree in principal, but it needs to be more explicit. Closing as 
WONTFIX, but happy to accept patches.

Original comment by willmcgugan on 10 Sep 2013 at 9:22