diff options
author | willmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-12-01 16:13:08 +0000 |
---|---|---|
committer | willmcgugan@gmail.com <willmcgugan@gmail.com@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-12-01 16:13:08 +0000 |
commit | 2a33b9e1af6600f32f9eaf1536e6a3fa2feb9ee3 (patch) | |
tree | 2a1f457399a4257ae03e122d50dc322930f5836a /fs/osfs | |
parent | ca813199fa92fbeecfc2a83178aa8391b8061cc6 (diff) | |
download | pyfilesystem-2a33b9e1af6600f32f9eaf1536e6a3fa2feb9ee3.tar.gz |
Implemented generic validatepath method and optimized normpath
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@837 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/osfs')
-rw-r--r-- | fs/osfs/__init__.py | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/osfs/__init__.py b/fs/osfs/__init__.py index 13511eb..b652299 100644 --- a/fs/osfs/__init__.py +++ b/fs/osfs/__init__.py @@ -88,10 +88,9 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS): } if platform.system() == 'Windows': - _invalid_path_chars = ''.join(chr(n) for n in xrange(31)) + '\\:*?"<>|' + _meta["invalid_path_chars"] = ''.join(chr(n) for n in xrange(31)) + '\\:*?"<>|' else: - _invalid_path_chars = '\0' - _re_invalid_path_chars = re.compile('|'.join(re.escape(c) for c in _invalid_path_chars), re.UNICODE) + _meta["invalid_path_chars"] = '\0' def __init__(self, root_path, thread_synchronize=_thread_synchronize_default, encoding=None, create=False, dir_mode=0700, use_long_paths=True): """ @@ -153,13 +152,8 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS): return p return p.decode(self.encoding, 'replace') - def _validate_path(self, path): - """Raise an error if there are any invalid characters in the path""" - if self._re_invalid_path_chars.search(path): - raise InvalidCharsInPathError(path) - def getsyspath(self, path, allow_none=False): - self._validate_path(path) + self.validatepath(path) path = relpath(normpath(path)).replace(u"/", os.sep) path = os.path.join(self.root_path, path) if not path.startswith(self.root_path): |