Skip to content

Commit ad4fdb4

Browse files
committed
Simplify a few pieces, mostly return statements
1 parent 924f695 commit ad4fdb4

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

scripts/portal-fetcher/openshift-docs-downloader.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,7 @@ def is_likely_external_link(url: str) -> bool:
8484
]
8585

8686
# Check if the path contains any domain-like patterns
87-
for pattern in domain_patterns:
88-
if pattern in path:
89-
return True
90-
91-
# Check for unusual path length which might indicate a malformed URL
92-
if len(path.split("/")) > 10: # Unusually deep path
93-
return True
94-
95-
return False
87+
return any(pattern in path for pattern in domain_patterns)
9688

9789

9890
def is_html_single_url(url: str) -> bool:
@@ -125,22 +117,16 @@ def is_in_scope(url: str, base_url: str) -> bool:
125117
# But also handle the case where the base URL doesn't include the actual page
126118
if "/html-single/" in base_path:
127119
# If this is a specific doc, make sure it's within that doc's URL path
128-
# Check if url_path starts with base_path or is the exact doc index
129-
is_in_scope = url_path.startswith(base_path) or url_path == base_path.removesuffix("/index")
120+
return url_path.startswith(base_path) or url_path == base_path.removesuffix("/index")
130121
else:
131122
# For entire docs, anything with openshift_container_platform/VERSION in scope
132123
try:
133-
base_parts = base_url.split("openshift_container_platform/")
134-
if len(base_parts) > 1:
135-
version = base_parts[1].split("/")[0]
136-
version_part = f"openshift_container_platform/{version}"
137-
is_in_scope = version_part in url and is_html_single_url(url)
138-
else:
139-
is_in_scope = False
124+
version_part = f"openshift_container_platform/{base_url.split('openshift_container_platform/')[1].split('/')[0]}"
125+
is_in_scope = version_part in url and is_html_single_url(url)
140126
except IndexError:
141127
is_in_scope = False
142128

143-
return is_in_scope
129+
return is_in_scope
144130

145131

146132
def get_local_path(url: str, output_dir: Path) -> Path:

0 commit comments

Comments
 (0)