def listdir(space, w_dirname): """Return a list containing the names of the entries in the directory. \tpath: path of directory to list The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.""" try: if space.isinstance_w(w_dirname, space.w_unicode): dirname = FileEncoder(space, w_dirname) result = rposix.listdir(dirname) w_fs_encoding = getfilesystemencoding(space) result_w = [space.call_method(space.wrap(s), "decode", w_fs_encoding) for s in result] else: dirname = space.str_w(w_dirname) result = rposix.listdir(dirname) result_w = [space.wrap(s) for s in result] except OSError, e: raise wrap_oserror2(space, e, w_dirname)
def listdir(space, w_dirname): """Return a list containing the names of the entries in the directory. \tpath: path of directory to list The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.""" try: if space.isinstance_w(w_dirname, space.w_unicode): dirname = FileEncoder(space, w_dirname) result = rposix.listdir(dirname) w_fs_encoding = getfilesystemencoding(space) result_w = [ space.call_method(space.wrap(s), "decode", w_fs_encoding) for s in result ] else: dirname = space.str_w(w_dirname) result = rposix.listdir(dirname) result_w = [space.wrap(s) for s in result] except OSError, e: raise wrap_oserror2(space, e, w_dirname)
def listdir(space, w_dirname): """Return a list containing the names of the entries in the directory. \tpath: path of directory to list The list is in arbitrary order. It does not include the special entries '.' and '..' even if they are present in the directory.""" try: if space.isinstance_w(w_dirname, space.w_unicode): dirname = FileEncoder(space, w_dirname) result = rposix.listdir(dirname) w_fs_encoding = getfilesystemencoding(space) len_result = len(result) result_w = [None] * len_result for i in range(len_result): w_bytes = space.wrap(result[i]) try: result_w[i] = space.call_method(w_bytes, "decode", w_fs_encoding) except OperationError, e: # fall back to the original byte string result_w[i] = w_bytes else:
dirname = FileEncoder(space, w_dirname) result = rposix.listdir(dirname) w_fs_encoding = getfilesystemencoding(space) len_result = len(result) result_w = [None] * len_result for i in range(len_result): w_bytes = space.wrap(result[i]) try: result_w[i] = space.call_method(w_bytes, "decode", w_fs_encoding) except OperationError, e: # fall back to the original byte string result_w[i] = w_bytes else: dirname = space.str0_w(w_dirname) result = rposix.listdir(dirname) result_w = [space.wrap(s) for s in result] except OSError, e: raise wrap_oserror2(space, e, w_dirname) return space.newlist(result_w) def pipe(space): "Create a pipe. Returns (read_end, write_end)." try: fd1, fd2 = os.pipe() except OSError, e: raise wrap_oserror(space, e) return space.newtuple([space.wrap(fd1), space.wrap(fd2)]) @unwrap_spec(mode=c_int) def chmod(space, w_path, mode):
def f(): return ', '.join(rposix.listdir(udir))
def f(): return u', '.join(rposix.listdir(udir))
dirname = FileEncoder(space, w_dirname) result = rposix.listdir(dirname) w_fs_encoding = getfilesystemencoding(space) len_result = len(result) result_w = [None] * len_result for i in range(len_result): w_bytes = space.wrap(result[i]) try: result_w[i] = space.call_method(w_bytes, "decode", w_fs_encoding) except OperationError, e: # fall back to the original byte string result_w[i] = w_bytes else: dirname = space.str0_w(w_dirname) result = rposix.listdir(dirname) result_w = [space.wrap(s) for s in result] except OSError, e: raise wrap_oserror2(space, e, w_dirname) return space.newlist(result_w) def pipe(space): "Create a pipe. Returns (read_end, write_end)." try: fd1, fd2 = os.pipe() except OSError, e: raise wrap_oserror(space, e) return space.newtuple([space.wrap(fd1), space.wrap(fd2)])