diff --git a/Makefile b/Makefile index 580a9c0..2622276 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ clean: install: $(PYTHON) setup.py build - $(PYTHON) setup.py develop + $(PYTHON) setup.py develop --user test: install $(PYTHON) $(TSCRIPT) diff --git a/fs/mountfs.py b/fs/mountfs.py index 860cdc4..5dde803 100644 --- a/fs/mountfs.py +++ b/fs/mountfs.py @@ -111,6 +111,14 @@ def _delegate(self, path): else: head_path = prefix tail_path = path[len(head_path):] + if tail_path == '': + # XXX - GIAMPAOLO: I did this because pyfs methods ( + # makedir, listdir etc.) treat "" as an alias for "/", + # which is stupid. We don't want to inherit this + # assumption in our code and fill it with + # "if path == '': path = '/'" all over the place + # so we do it here. + tail_path = '/' if type(object) is MountFS.DirMount: return object.fs, head_path, tail_path diff --git a/fs/tests/__init__.py b/fs/tests/__init__.py index 4227ddc..4c86cf3 100644 --- a/fs/tests/__init__.py +++ b/fs/tests/__init__.py @@ -83,10 +83,9 @@ def test_meta(self): self.assertFalse(self.fs.hasmeta(meta_name)) def test_root_dir(self): - self.assertTrue(self.fs.isdir("")) self.assertTrue(self.fs.isdir("/")) # These may be false (e.g. empty dict) but mustn't raise errors - self.fs.getinfo("") + self.fs.getinfo("/") self.assertTrue(self.fs.getinfo("/") is not None) def test_getsyspath(self): @@ -218,7 +217,7 @@ def check_unicode(items): self.assertEqual(len(d1), 4) self.assertEqual(sorted(d1), [u"a", u"b", u"bar", u"foo"]) check_unicode(d1) - d1 = self.fs.listdir("") + d1 = self.fs.listdir("/") self.assertEqual(len(d1), 4) self.assertEqual(sorted(d1), [u"a", u"b", u"bar", u"foo"]) check_unicode(d1) @@ -283,7 +282,7 @@ def check_equal(items, target): self.assertEqual(len(d1), 4) check_equal(d1, [u"a", u"b", u"bar", u"foo"]) check_unicode(d1) - d1 = self.fs.listdirinfo("") + d1 = self.fs.listdirinfo("/") self.assertEqual(len(d1), 4) check_equal(d1, [u"a", u"b", u"bar", u"foo"]) check_unicode(d1) diff --git a/fs/wrapfs/__init__.py b/fs/wrapfs/__init__.py index 023816c..1ee6831 100644 --- a/fs/wrapfs/__init__.py +++ b/fs/wrapfs/__init__.py @@ -188,7 +188,8 @@ def isfile(self, path): return self.wrapped_fs.isfile(self._encode(path)) @rewrite_errors - def listdir(self, path="", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): + def listdir(self, path="/", wildcard=None, full=False, absolute=False, + dirs_only=False, files_only=False): kwds = dict(wildcard=wildcard, full=full, absolute=absolute, @@ -242,7 +243,7 @@ def ilistdir(self, path="", wildcard=None, full=False, absolute=False, dirs_only yield e @rewrite_errors - def listdirinfo(self, path="", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): + def listdirinfo(self, path="/", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): kwds = dict(wildcard=wildcard, full=full, absolute=absolute, diff --git a/fs/wrapfs/hidefs.py b/fs/wrapfs/hidefs.py index c0adf32..3aef0be 100644 --- a/fs/wrapfs/hidefs.py +++ b/fs/wrapfs/hidefs.py @@ -43,7 +43,7 @@ def exists(self, path): return False return super(HideFS, self).exists(path) - def listdir(self, path="", *args, **kwargs): + def listdir(self, path="/", *args, **kwargs): entries = super(HideFS, self).listdir(path, *args, **kwargs) entries = [entry for entry in entries if not self._should_hide(entry)] return entries