Skip to content

Commit 12830b6

Browse files
committed
Formatting.
1 parent f103152 commit 12830b6

6 files changed

Lines changed: 22 additions & 8 deletions

File tree

aiohttp_aiofiles_tutorial/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414

1515

1616
async def init_script():
17-
"""Initiate script by preparing an output file prior to executing tasks."""
17+
"""Prepare output file & kickoff task creation/execution."""
1818
start_time = timer()
1919
async with aiofiles.open(EXPORT_FILE, mode="w+") as outfile:
2020
await outfile.write("title,description,primary_tag,url,published_at\n")
2121
await execute_fetcher_tasks(outfile)
2222
await outfile.close()
23-
LOGGER.success(f"Executed {__name__} in {time.perf_counter() - start_time:0.2f} seconds.")
23+
LOGGER.success(
24+
f"Executed {__name__} in {time.perf_counter() - start_time:0.2f} seconds."
25+
)
2426

2527

2628
async def execute_fetcher_tasks(outfile: AsyncIOFile):

aiohttp_aiofiles_tutorial/fetcher.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77

88

99
async def fetch_url_and_save_data(
10-
session: ClientSession, url: str, outfile: AsyncIOFile, total_count: int, i: int
10+
session: ClientSession,
11+
url: str,
12+
outfile: AsyncIOFile,
13+
total_count: int,
14+
i: int,
1115
):
1216
"""
1317
Fetch raw HTML from a URL prior to parsing.

aiohttp_aiofiles_tutorial/parser.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ async def parse_html_page_data(html: str, url: str) -> str:
2222
.replace('"', "`")
2323
.replace("'", "`")
2424
)
25-
primary_tag = soup.head.select_one("meta[property='article:tag']").get("content")
25+
primary_tag = soup.head.select_one("meta[property='article:tag']").get(
26+
"content"
27+
)
2628
published_at = (
2729
soup.head.select_one("meta[property='article:published_time']")
2830
.get("content")

aiohttp_aiofiles_tutorial/tasks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from .fetcher import fetch_url_and_save_data
1010

1111

12-
async def create_tasks(session: ClientSession, urls: List[str], outfile: AsyncIOFile) -> List[Task]:
12+
async def create_tasks(
13+
session: ClientSession, urls: List[str], outfile: AsyncIOFile
14+
) -> List[Task]:
1315
"""
1416
Create asyncio tasks to execute the `fetch_url_and_save_title` coroutine.
1517
@@ -21,6 +23,8 @@ async def create_tasks(session: ClientSession, urls: List[str], outfile: AsyncIO
2123
"""
2224
task_list = []
2325
for i, url in enumerate(urls):
24-
task = asyncio.create_task(fetch_url_and_save_data(session, url, outfile, len(urls), i))
26+
task = asyncio.create_task(
27+
fetch_url_and_save_data(session, url, outfile, len(urls), i)
28+
)
2529
task_list.append(task)
2630
return task_list

aiohttp_aiofiles_tutorial/writer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from .parser import parse_html_page_data
66

77

8-
async def write_to_outfile(html: str, url: str, outfile: AsyncIOFile, total_count: int, i: int):
8+
async def write_to_outfile(
9+
html: str, url: str, outfile: AsyncIOFile, total_count: int, i: int
10+
):
911
"""
1012
Write contents of fetched URL to new file in local directory.
1113

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ profile = "black"
5252
src_paths = ["aiohttp_aiofiles_tutorial"]
5353

5454
[tool.black]
55-
line-length = 100
55+
line-length = 80

0 commit comments

Comments
 (0)