文件系统

class litestar.file_system.BaseLocalFileSystem

基类:FileSystemProtocol

本地文件系统的基类。

async info(path: PathType, **kwargs: Any) FileInfo

返回给定 pathFileInfo

async open(file: PathType, mode: str, buffering: int = -1) AsyncFile[AnyStr]

Return a file-like object from the filesystem.

备注

  • The return value must be a context-manager

参数:
  • file -- Path to the target file.

  • mode -- Mode, similar to the built open.

  • buffering -- Buffer size.

__init__()
class litestar.file_system.FileSystemAdapter

基类:object

Wrapper around a FileSystemProtocol, normalising its interface.

__init__(file_system: FileSystemProtocol) None

Initialize an adapter from a given file_system

参数:

file_system -- A filesystem class adhering to the FileSystemProtocol

async info(path: PathType) FileInfo

Proxies the call to the underlying FS Spec's info method, ensuring it's done in an async fashion and with strong typing.

参数:

path -- A file path to load the info for.

返回:

A dictionary of file info.

async open(file: PathType, mode: OpenBinaryMode = 'rb', buffering: int = -1) AsyncFile[bytes]

Return a file-like object from the filesystem.

备注

  • The return value must function correctly in a context with block.

参数:
  • file -- Path to the target file.

  • mode -- Mode, similar to the built open.

  • buffering -- Buffer size.

async static parse_stat_result(path: PathType, result: stat_result) FileInfo

Convert a stat_result instance into a FileInfo.

参数:
  • path -- The file path for which the stat_result is provided.

  • result -- The stat_result instance.

返回:

A dictionary of file info.