示例#1
0
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
示例#2
0
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)
示例#3
0
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)
示例#5
0
    def test_splitdrive(self):
        self.assertEqual(posixpath.splitdrive("/foo/bar"), ("", "/foo/bar"))

        self.assertRaises(TypeError, posixpath.splitdrive)
示例#6
0
 def update_event(self, inp=-1):
     self.set_output_val(0, posixpath.splitdrive(self.input(0)))