mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
uio: add stubs and docs for uio module
Issue: https://github.com/pybricks/support/issues/236
This commit is contained in:
committed by
laurensvalk
parent
0865a58632
commit
532639b820
@@ -79,6 +79,7 @@ findings on our `support page`_ so we can make Pybricks even better.
|
||||
|
||||
micropython
|
||||
uerrno
|
||||
uio
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
:mod:`uio` -- Input/output streams
|
||||
==================================
|
||||
|
||||
.. note:: This module is not available on the BOOST Move Hub.
|
||||
|
||||
.. automodule:: uio
|
||||
@@ -17,6 +17,7 @@ packages = [
|
||||
{ include = "pybricks", from = "src" },
|
||||
{ include = "micropython", from = "src" },
|
||||
{ include = "uerrno", from = "src" },
|
||||
{ include = "uio", from = "src" },
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2021 The Pybricks Authors
|
||||
#
|
||||
# Portions of documentation copied from:
|
||||
# https://raw.githubusercontent.com/micropython/micropython/1e6d18c915ccea0b6a19ffec9710d33dd7e5f866/docs/library/uio.rst
|
||||
# Copyright (c) 2014-2021, Damien P. George, Paul Sokolovsky, and contributors
|
||||
|
||||
"""
|
||||
This module contains additional types of ``stream`` (file-like) objects
|
||||
and helper functions.
|
||||
"""
|
||||
|
||||
# TODO: open() is not implemented on Powered Up hubs
|
||||
|
||||
from typing import overload
|
||||
|
||||
# TODO: MicroPython streams implement '__enter__', '__exit__', 'close', 'read',
|
||||
# 'readinto', 'readline', 'write', 'flush', 'getvalue', 'seek', 'tell'
|
||||
# and are iterable
|
||||
|
||||
|
||||
class BytesIO:
|
||||
@overload
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, initial_bytes: bytes) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, alloc_size: int) -> None:
|
||||
...
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""
|
||||
A binary stream using an in-memory bytes buffer.
|
||||
|
||||
Args:
|
||||
initial_bytes: Optional bytes-like object that contains initial data.
|
||||
alloc_size: Optional number of preallocated bytes.
|
||||
"""
|
||||
|
||||
|
||||
class StringIO:
|
||||
@overload
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, initial_value: str) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, alloc_size: int) -> None:
|
||||
...
|
||||
|
||||
def __init__(self, *args) -> None:
|
||||
"""
|
||||
A binary stream using an in-memory string buffer.
|
||||
|
||||
Args:
|
||||
initial_value: Optional string object that contains initial data.
|
||||
alloc_size: Optional number of preallocated bytes.
|
||||
"""
|
||||
Reference in New Issue
Block a user