Skip to content

Commit b13a0d8

Browse files
committed
[fdiff.remote] add function docstrings
1 parent 36d4a05 commit b13a0d8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/fdiff/remote.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010

1111

1212
def _get_filepath_from_url(url, dirpath):
13+
"""Returns filepath from base file name in URL and directory path."""
1314
url_path_list = urllib.parse.urlsplit(url)
1415
abs_filepath = url_path_list.path
1516
basepath = os.path.split(abs_filepath)[-1]
1617
return os.path.join(dirpath, basepath)
1718

1819

1920
async def async_fetch(session, url):
21+
"""Asynchronous I/O HTTP GET request with a ClientSession instantiated from the aiohttp library."""
2022
async with session.get(url) as response:
2123
status = response.status
2224
if status != 200:
@@ -27,6 +29,10 @@ async def async_fetch(session, url):
2729

2830

2931
async def async_fetch_and_write(session, url, dirpath):
32+
"""Asynchronous I/O HTTP GET request with a ClientSession instantiated from the aiohttp library, followed
33+
by an asynchronous I/O file write of the binary to disk with the aiofiles library.
34+
35+
:returns `FWRes` namedtuple with url, filepath, http_status, write_success fields"""
3036
FWResponse = namedtuple(
3137
"FWRes", ["url", "filepath", "http_status", "write_success"]
3238
)
@@ -45,6 +51,10 @@ async def async_fetch_and_write(session, url, dirpath):
4551

4652

4753
async def create_async_get_request_session_and_run(urls, dirpath):
54+
"""Creates an aiohttp library ClientSession and performs asynchronous GET requests +
55+
binary file writes with the binary response from the GET request.
56+
57+
:returns list of asyncio Tasks that include `FWRes` namedtuple instances (defined in async_fetch_and_write)"""
4858
async with aiohttp.ClientSession() as session:
4959
tasks = []
5060
for url in urls:

0 commit comments

Comments
 (0)