Skip to content

Commit 42e3613

Browse files
authored
Merge pull request #256 from realpython/python-connectivity-checker-FQA
Update code as per FQA
2 parents 32f5511 + 709a27d commit 42e3613

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

python-site-connectivity-checker/source_code_final/rpchecker/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def main():
1212
"""Run RP Checker."""
1313
user_args = read_user_cli_args()
1414
urls = _get_websites_urls(user_args)
15-
if len(urls) == 0:
15+
if not urls:
1616
print("Error: no URLs to check", file=sys.stderr)
1717
sys.exit(1)
1818

@@ -34,7 +34,7 @@ def _read_urls_from_file(file):
3434
if file_path.is_file():
3535
with file_path.open() as urls_file:
3636
urls = [url.strip() for url in urls_file]
37-
if len(urls) > 0:
37+
if urls:
3838
return urls
3939
print(f"Error: empty input file, {file}", file=sys.stderr)
4040
else:

python-site-connectivity-checker/source_code_final/rpchecker/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def site_is_online(url, timeout=2):
9-
"""Return a True if the target URL is online.
9+
"""Return True if the target URL is online.
1010
1111
Raise an exception otherwise.
1212
"""
@@ -26,7 +26,7 @@ def site_is_online(url, timeout=2):
2626

2727

2828
async def site_is_online_async(url, timeout=2):
29-
"""Return a True if the target URL is online.
29+
"""Return True if the target URL is online.
3030
3131
Raise an exception otherwise.
3232
"""

python-site-connectivity-checker/source_code_step_2/rpchecker/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def site_is_online(url, timeout=2):
6-
"""Return a True if the target URL is online.
6+
"""Return True if the target URL is online.
77
88
Raise an exception otherwise.
99
"""

python-site-connectivity-checker/source_code_step_3/rpchecker/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def site_is_online(url, timeout=2):
6-
"""Return a True if the target URL is online.
6+
"""Return True if the target URL is online.
77
88
Raise an exception otherwise.
99
"""

python-site-connectivity-checker/source_code_step_4/rpchecker/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
"""Run RP Checker."""
1010
user_args = read_user_cli_args()
1111
urls = _get_websites_urls(user_args)
12-
if len(urls) == 0:
12+
if not urls:
1313
print("Error: no URLs to check", file=sys.stderr)
1414
sys.exit(1)
1515
_synchronous_check(urls)
@@ -27,7 +27,7 @@ def _read_urls_from_file(file):
2727
if file_path.is_file():
2828
with file_path.open() as urls_file:
2929
urls = [url.strip() for url in urls_file]
30-
if len(urls) > 0:
30+
if urls:
3131
return urls
3232
print(f"Error: empty input file, {file}", file=sys.stderr)
3333
else:

python-site-connectivity-checker/source_code_step_4/rpchecker/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
def site_is_online(url, timeout=2):
6-
"""Return a True if the target URL is online.
6+
"""Return True if the target URL is online.
77
88
Raise an exception otherwise.
99
"""

python-site-connectivity-checker/source_code_step_5/rpchecker/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def main():
1212
"""Run RP Checker."""
1313
user_args = read_user_cli_args()
1414
urls = _get_websites_urls(user_args)
15-
if len(urls) == 0:
15+
if not urls:
1616
print("Error: no URLs to check", file=sys.stderr)
1717
sys.exit(1)
1818

@@ -34,7 +34,7 @@ def _read_urls_from_file(file):
3434
if file_path.is_file():
3535
with file_path.open() as urls_file:
3636
urls = [url.strip() for url in urls_file]
37-
if len(urls) > 0:
37+
if urls:
3838
return urls
3939
print(f"Error: empty input file, {file}", file=sys.stderr)
4040
else:

python-site-connectivity-checker/source_code_step_5/rpchecker/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
def site_is_online(url, timeout=2):
9-
"""Return a True if the target URL is online.
9+
"""Return True if the target URL is online.
1010
1111
Raise an exception otherwise.
1212
"""
@@ -26,7 +26,7 @@ def site_is_online(url, timeout=2):
2626

2727

2828
async def site_is_online_async(url, timeout=2):
29-
"""Return a True if the target URL is online.
29+
"""Return True if the target URL is online.
3030
3131
Raise an exception otherwise.
3232
"""

0 commit comments

Comments
 (0)