Skip to content

Commit 82a01fb

Browse files
committed
[fdiff.remote] refactor I/O function: move to a different module
1 parent d7a6c07 commit 82a01fb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/fdiff/remote.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import aiohttp
55
import asyncio
6-
import aiofiles
6+
7+
from fdiff.aio import async_write_bin
78

89

910
def _get_filepath_from_url(url, dirpath):
@@ -13,11 +14,6 @@ def _get_filepath_from_url(url, dirpath):
1314
return os.path.join(dirpath, basepath)
1415

1516

16-
async def async_write(path, binary):
17-
async with aiofiles.open(path, "wb") as f:
18-
await f.write(binary)
19-
20-
2117
async def async_fetch(session, url):
2218
async with session.get(url) as response:
2319
status = response.status
@@ -35,7 +31,8 @@ async def async_fetch_and_write(session, url, dirpath):
3531
return url, filepath, False
3632
else:
3733
filepath = _get_filepath_from_url(url, dirpath)
38-
await async_write(filepath, binary)
34+
await async_write_bin(filepath, binary)
35+
# TODO: refactor to namedtuple?
3936
return url, filepath, True
4037

4138

0 commit comments

Comments
 (0)