diff options
author | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2009-05-06 06:57:55 +0000 |
---|---|---|
committer | rfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f> | 2009-05-06 06:57:55 +0000 |
commit | a739fee6eeda8ff4a039655a88bcc520628e5d86 (patch) | |
tree | b18020671148f10c13133c160b7e9e6a051c4c1d | |
parent | 27ba38114e1b4f834ea24e4f39be3cd8f5d9d1ae (diff) | |
download | pyfilesystem-a739fee6eeda8ff4a039655a88bcc520628e5d86.tar.gz |
some small helper tweaks
git-svn-id: http://pyfilesystem.googlecode.com/svn/branches/rfk-ideas@141 67cdc799-7952-0410-af00-57a81ceafa0f
-rw-r--r-- | fs/helpers.py | 6 | ||||
-rw-r--r-- | fs/osfs.py | 7 | ||||
-rw-r--r-- | fs/tests.py | 10 |
3 files changed, 17 insertions, 6 deletions
diff --git a/fs/helpers.py b/fs/helpers.py index d79e4e1..e47082b 100644 --- a/fs/helpers.py +++ b/fs/helpers.py @@ -9,11 +9,9 @@ from itertools import chain def iteratepath(path, numsplits=None): """Iterate over the individual components of a path.""" - path = normpath(path) + path = makerelative(normpath(path)) if not path: return [] - if path[0] == "/": - path = path[1:] if numsplits == None: return path.split('/') else: @@ -57,6 +55,8 @@ def normpath(path): components.append(comp) if path[0] in "\\/": + if not components: + components = [""] components.insert(0,"") return "/".join(components) @@ -22,8 +22,7 @@ class OSFS(FS): def __init__(self, root_path, dir_mode=0700, thread_synchronize=True): FS.__init__(self, thread_synchronize=thread_synchronize) - expanded_path = normpath(os.path.expanduser(os.path.expandvars(root_path))) - + expanded_path = makeabsolute(normpath(os.path.expanduser(os.path.expandvars(root_path)))) if not os.path.exists(expanded_path): raise DirectoryNotFoundError(expanded_path, msg="Root directory does not exist: %(path)s") if not os.path.isdir(expanded_path): @@ -176,7 +175,9 @@ class OSFS(FS): def getxattr(self, path, key, default=None): try: - return xattr.xattr(self.getsyspath(path)).get(key,default) + return xattr.xattr(self.getsyspath(path)).get(key) + except KeyError: + return default except IOError, e: raise OperationFailedError('get extended attribute', path=path, details=e) diff --git a/fs/tests.py b/fs/tests.py index 0f2a0d9..7bee141 100644 --- a/fs/tests.py +++ b/fs/tests.py @@ -523,6 +523,7 @@ class TestHelpers(unittest.TestCase): ("/a/b/c", "/a/b/c"), ("a/b/c", "a/b/c"), ("a/b/../c/", "a/c"), + ("/","/"), ] for path, result in tests: self.assertEqual(normpath(path), result) @@ -657,6 +658,13 @@ class TestOSFS(unittest.TestCase,FSTestCases): def check(self, p): return os.path.exists(os.path.join(self.temp_dir, makerelative(p))) +#try: +# import xattr +#except ImportError: +# pass +#else: +# TestOSFS.__bases__ = TestOSFS.__bases__ + (XAttrTestCases,) + class TestSubFS(unittest.TestCase,FSTestCases): @@ -721,6 +729,8 @@ class TestS3FS(unittest.TestCase,FSTestCases): bucket = "test-s3fs.rfk.id.au" def setUp(self): + import nose + raise nose.SkipTest self.fs = s3fs.S3FS(self.bucket,"/unittest/files") self._clear() |