Skip to content

Commit

Permalink
pdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
bobfang1992 committed Nov 18, 2021
1 parent 66f2cca commit 02f2d66
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
9 changes: 8 additions & 1 deletion src/pytomlpp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
"""Python wrapper for Toml++."""
"""
Python wrapper for Toml++.
Install from [PyPI](https://pypi.org/project/pytomlpp/)
"""

__all__ = ["DecodeError", "dumps", "loads", "dump", "load"]

Expand Down
36 changes: 15 additions & 21 deletions src/pytomlpp/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,24 @@


def dumps(data: Dict[Any, Any]) -> str:
"""Serialise data to TOML as string.
"""Serialise data to TOML string.
Args:
data: data to serialise
data (Dict[Any, Any]): input data
Returns:
serialised data
str: seralised data
"""
return _impl.dumps(data)


def dump(data: Dict[Any, Any], fl: FilePathOrObject, mode: str = "w") -> None:
"""Serialise data to TOML.
"""Serialise data to TOML file
Args:
data: data to serialise
fl (io.TextIOBase, str or os.Pathlike):
file-object to write to (supports ``write``)
or a file name (str, os.Pathlike) that supports ``open``
mode (str): opening mode. Either "w" or "wt" (text), or "wb" (binary). Defaults to "w".
Ignored if fl supports ``write``.
data (Dict[Any, Any]): input data
fl (FilePathOrObject): file like object or path
mode (str, optional): mode to write the file, support "w", "wt" (text) or "wb" (binary). Defaults to "w".
"""
data = _impl.dumps(data)
if mode == "wb":
Expand All @@ -42,29 +39,26 @@ def dump(data: Dict[Any, Any], fl: FilePathOrObject, mode: str = "w") -> None:


def loads(data: str) -> Dict[Any, Any]:
"""Deserialise from TOML as dictionary.
"""Deserialise from TOML string to python dict.
Args:
data (str): data to deserialise
data (str): TOML string
Returns:
deserialised data
Returns:
Dict[Any, Any]: deserialised data
"""
return _impl.loads(data)


def load(fl: FilePathOrObject, mode: str = "r") -> Dict[Any, Any]:
"""Deserialise from TOML.
"""Deserialise from TOML file to python dict.
Args:
fl (io.TextIOBase, str or os.Pathlike):
file-object to read from (supports ``read``)
or a file name (str, os.Pathlike) that supports ``open``
mode (str): opening mode. Either "r" or "rt" (text) or "rb" (binary). Defaults to "r".
Ignored if fl supports ``read``.
fl (FilePathOrObject): file like object or path
mode (str, optional): mode to read the file, support "r", "rt" (text) or "rb" (binary). Defaults to "r".
Returns:
deserialised data
Dict[Any, Any]: deserialised data
"""

if hasattr(fl, "read"):
Expand Down

0 comments on commit 02f2d66

Please sign in to comment.