def escape(pathname): """Escape all special characters. """ # Escaping is done by wrapping any of "*?[" between square brackets. # Metacharacters do not work in the drive part and shouldn't be escaped. drive, pathname = posixpath.splitdrive(pathname) if isinstance(pathname, bytes): pathname = magic_check_bytes.sub(br'[\1]', pathname) else: pathname = magic_check.sub(r'[\1]', pathname) return drive + pathname
def find_library(dirpath='.'): """Find library. Return the path of the first library found above the given path. Return None if no library is found. """ dirpath = posixpath.abspath(dirpath) _, dirpath = posixpath.splitdrive(dirpath) while True: if is_library(dirpath): return dirpath elif dirpath in ('/', ''): return None else: dirpath, _ = posixpath.split(dirpath)
def find_library(dirpath='.'): """Find library. Return the path of the first library found above the given path. Return None if no library is found. """ dirpath = posixpath.abspath(dirpath) _, dirpath = posixpath.splitdrive(dirpath) while True: if is_library(dirpath): return dirpath elif dirpath in ('/', ''): return None else: dirpath, _ = posixpath.split(dirpath)
def test_splitdrive(self): self.assertEqual(posixpath.splitdrive("/foo/bar"), ("", "/foo/bar")) self.assertRaises(TypeError, posixpath.splitdrive)
def test_splitdrive(self): self.assertEqual(posixpath.splitdrive("/foo/bar"), ("", "/foo/bar")) self.assertRaises(TypeError, posixpath.splitdrive)
def update_event(self, inp=-1): self.set_output_val(0, posixpath.splitdrive(self.input(0)))