Pathlib support for asyncio
Project description
aiopathlib: Pathlib support for asyncio
aiopathlib is written in Python, for handling local disk files in asyncio applications.
Base on aiofiles
and just like pathlib, but use await.
with open('filename', 'w') as f:
f.write('My file contents')
text = await aiopathlib.AsyncPath('filename').read_text()
print(text)
'My file contents'
content = await aiopathlib.AsyncPath(Path('filename')).read_bytes()
print(content)
b'My file contents'
Asynchronous interface to create folder.
apath = AsyncPath('dirname/subpath')
if not await apath.exists():
await apath.mkdir(parents=True)
Features
- a file API very similar to Python's standard package
pathlib
, blocking API - support for buffered and unbuffered binary files, and buffered text files
- support for
async
/await
(:PEP:492
) constructs
Installation
To install aiofiles, simply:
$ pip install aiopathlib
Usage
These functions are awaitable
read_text
read_bytes
read_json
write_text
write_bytes
write_json
mkdir
exists
rename
remove
/unlink
stat
lstat
is_file
is_dir
is_symlink
is_fifo
is_mount
is_block_device
is_char_device
is_socket
History
0.2.0 (2021-08-29)
- Make
AsyncPath
be subclass ofpathlib.Path
. - Add github action to show test coverage.
0.1.3 (2021-08-28)
- Add makefile.
- Test all functions.
- Fix rename method error.
- Support sync pathlib methods.
0.1.0 (2021-06-14)
- Introduced a changelog.
- Publish at gitee.
Contributing
Contributions are very welcome.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiopathlib-0.2.1.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for aiopathlib-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf3aa6819753c0ed6458cbb7ea65dd594d529e9ddea168a9fc009fee88b4aae3 |
|
MD5 | 2ddbf2eed51f06407328a600f463c498 |
|
BLAKE2b-256 | c83552e594d4e4676bbb036c2743137c6d06b4feec2caf5a5e0bdc0905b58350 |