Filesystem Module

class judge0.filesystem.File(*, name: str, content: str | bytes | None = None)

File object for storing file content.

Parameters:
  • name (str) – File name.

  • content (str or bytes, optional) – File content. If str is provided, it will be encoded to bytes.

name: str
content: str | bytes | None
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class judge0.filesystem.Filesystem(*, files: list[File] = [])

Filesystem object for storing multiple files.

Parameters:

content (str or bytes or File or Iterable[File] or Filesystem, optional) – Filesystem content. If str or bytes is provided, it will be decoded to files.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

files: list[File]
encode()

Encode Filesystem object to bytes.

Return type:

bytes

find(name)

Find file by name in Filesystem object.

Parameters:

name (str) – File name to find.

Returns:

Found File object or None if not found.

Return type:

File or None