aiomegfile.filesystem.stdio module

class aiomegfile.filesystem.stdio.AioSTDReader(mode: str)[source]

Bases: AioReadable

Async wrapper around sys.stdin.

async close() None

Close reader handle.

stdin itself is not closed.

property mode: str

Return open mode.

Returns:

Open mode.

Return type:

str

property name: str

Return reader name.

Returns:

Stream name.

Return type:

str

async read(size: int | None = None) AnyStr[source]

Read data from stdin.

Parameters:

size – Maximum size to read.

Returns:

Read data.

Return type:

T.AnyStr

async readline(size: int | None = None) AnyStr[source]

Read one line from stdin.

Parameters:

size – Maximum size to read.

Returns:

Line data.

Return type:

T.AnyStr

async tell() int[source]

Return current offset.

Raises:

io.UnsupportedOperation – Always raised for stdio stream.

class aiomegfile.filesystem.stdio.AioSTDWriter(path: str, mode: str)[source]

Bases: AioWritable

Async wrapper around sys.stdout or sys.stderr.

async close() None

Close writer handle.

stdout/stderr itself is not closed.

async flush() None[source]

Flush writer buffer.

property mode: str

Return open mode.

Returns:

Open mode.

Return type:

str

property name: str

Return writer name.

Returns:

Stream name.

Return type:

str

async tell() int[source]

Return current offset.

Raises:

io.UnsupportedOperation – Always raised for stdio stream.

async write(data: AnyStr) int[source]

Write data to stdout or stderr.

Parameters:

data – Data to write.

Returns:

Number of written items.

Return type:

int

class aiomegfile.filesystem.stdio.StdioFileSystem[source]

Bases: BaseFileSystem

Filesystem adapter for stdio:// paths.

async absolute(path: str) str[source]

Return path unchanged for stdio stream.

Parameters:

path – Path without protocol.

Returns:

Original path.

Return type:

str

build_uri(path: str) str

Build stdio URI from path part.

Parameters:

path – Path without protocol.

Returns:

URI string.

Return type:

str

async exists(path: str, followlinks: bool = False) bool[source]

Return True when path is a valid stdio stream.

Parameters:
  • path – Path without protocol.

  • followlinks – Unused compatibility argument.

Returns:

Whether path is valid stdio path.

Return type:

bool

classmethod from_uri(uri: str)

Create a new filesystem instance from URI.

Parameters:

uri – URI string.

Returns:

New filesystem instance.

Return type:

StdioFileSystem

async is_dir(path: str, followlinks: bool = False) bool[source]

Return False for stdio streams.

Parameters:
  • path – Path without protocol.

  • followlinks – Unused compatibility argument.

Returns:

Always False.

Return type:

bool

async is_file(path: str, followlinks: bool = False) bool[source]

Return True when path is a valid stdio stream.

Parameters:
  • path – Path without protocol.

  • followlinks – Unused compatibility argument.

Returns:

Whether path is valid stdio path.

Return type:

bool

async mkdir(path: str, mode: int = 511, parents: bool = False, exist_ok: bool = False) None[source]

Directory operation is unsupported for stdio stream.

Parameters:
  • path – Path without protocol.

  • mode – Unused compatibility argument.

  • parents – Unused compatibility argument.

  • exist_ok – Unused compatibility argument.

Raises:

NotADirectoryError – Always raised.

open(path: str, mode: str = 'r', buffering: int = -1, encoding: str | None = None, errors: str | None = None, newline: str | None = None, **kwargs: Any) AsyncContextManager[Any][source]

Open stdio stream in read or write mode.

Parameters:
  • path – Path without protocol.

  • mode – Stream mode. Supports rb, wb, rt, wt, r, w.

  • buffering – Unused compatibility argument.

  • encoding – Unused compatibility argument.

  • errors – Unused compatibility argument.

  • newline – Unused compatibility argument.

  • kwargs – Unused compatibility arguments.

Raises:

ValueError – If mode/path is not acceptable.

Returns:

Async stdio reader or writer.

Return type:

T.AsyncContextManager[T.Any]

parse_uri(uri: str) str[source]

Parse path part from URI.

Parameters:

uri – URI string.

Returns:

Path without protocol.

Return type:

str

protocol = 'stdio'
async remove(path: str, missing_ok: bool = False) None[source]

Remove operation is unsupported for stdio stream.

Parameters:
  • path – Path without protocol.

  • missing_ok – Unused compatibility argument.

Raises:

OSError – Always raised.

same_endpoint(other_filesystem: BaseFileSystem) bool[source]

Return whether filesystem points to same stdio endpoint.

Parameters:

other_filesystem – Filesystem to compare.

Returns:

True when both are StdioFileSystem.

Return type:

bool

scandir(path: str) AsyncContextManager[AsyncIterator[FileEntry]][source]

Directory scan is unsupported for stdio stream.

Parameters:

path – Path without protocol.

Raises:

NotADirectoryError – Always raised.

scanfile(path: str, sort: bool = False) AsyncContextManager[AsyncIterator[FileEntry]][source]

File scan is unsupported for stdio stream.

Parameters:
  • path – Path without protocol.

  • sort – Compatibility flag for protocol-aligned scanfile APIs.

Raises:

NotADirectoryError – Always raised.

async stat(path: str, followlinks: bool = False) StatResult[source]

Stat operation is unsupported for stdio stream.

Parameters:
  • path – Path without protocol.

  • followlinks – Unused compatibility argument.

Raises:

OSError – Always raised.