Skip to content

Commit 36d4a05

Browse files
committed
[fdiff.remote] refactor function return to tuple to namedtuple
1 parent 82a01fb commit 36d4a05

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/fdiff/remote.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os.path
22
import urllib.parse
33

4+
from collections import namedtuple
5+
46
import aiohttp
57
import asyncio
68

@@ -25,15 +27,21 @@ async def async_fetch(session, url):
2527

2628

2729
async def async_fetch_and_write(session, url, dirpath):
30+
FWResponse = namedtuple(
31+
"FWRes", ["url", "filepath", "http_status", "write_success"]
32+
)
2833
url, status, binary = await async_fetch(session, url)
2934
if status != 200:
3035
filepath = None
31-
return url, filepath, False
36+
write_success = False
3237
else:
3338
filepath = _get_filepath_from_url(url, dirpath)
3439
await async_write_bin(filepath, binary)
35-
# TODO: refactor to namedtuple?
36-
return url, filepath, True
40+
write_success = True
41+
42+
return FWResponse(
43+
url=url, filepath=filepath, http_status=status, write_success=write_success
44+
)
3745

3846

3947
async def create_async_get_request_session_and_run(urls, dirpath):

0 commit comments

Comments
 (0)