ultralytics-actions 0.0.65__py3-none-any.whl → 0.0.67__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- actions/__init__.py +1 -1
- actions/utils/common_utils.py +14 -12
- {ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/METADATA +1 -1
- {ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/RECORD +8 -8
- {ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/WHEEL +0 -0
- {ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/entry_points.txt +0 -0
- {ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/licenses/LICENSE +0 -0
- {ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/top_level.txt +0 -0
actions/__init__.py
CHANGED
actions/utils/common_utils.py
CHANGED
@@ -20,15 +20,14 @@ REQUESTS_HEADERS = {
|
|
20
20
|
"Sec-Fetch-Mode": "navigate",
|
21
21
|
"Sec-Fetch-User": "?1",
|
22
22
|
"Sec-Fetch-Dest": "document",
|
23
|
-
"Referer": "https://www.google.com/",
|
24
|
-
"Origin": "https://www.google.com/",
|
25
23
|
}
|
26
24
|
BAD_HTTP_CODES = frozenset(
|
27
25
|
{
|
28
|
-
|
26
|
+
204, # No content
|
29
27
|
# 403, # Forbidden - client lacks permission to access the resource (commented as works in browser typically)
|
30
28
|
404, # Not Found - requested resource doesn't exist
|
31
29
|
405, # Method Not Allowed - HTTP method not supported for this endpoint
|
30
|
+
406, # Not Acceptable - server can't generate response matching client's acceptable headers
|
32
31
|
410, # Gone - resource permanently removed
|
33
32
|
500, # Internal Server Error - server encountered an error
|
34
33
|
502, # Bad Gateway - upstream server sent invalid response
|
@@ -141,7 +140,7 @@ def brave_search(query, api_key, count=5):
|
|
141
140
|
return [result.get("url") for result in results if result.get("url")]
|
142
141
|
|
143
142
|
|
144
|
-
def is_url(url, session=None, check=True, max_attempts=3, timeout=
|
143
|
+
def is_url(url, session=None, check=True, max_attempts=3, timeout=3, return_url=False, redirect=False):
|
145
144
|
"""Check if string is URL and optionally verify it exists, with fallback for GitHub repos."""
|
146
145
|
try:
|
147
146
|
# Check allow list
|
@@ -190,7 +189,7 @@ def is_url(url, session=None, check=True, max_attempts=3, timeout=2, return_url=
|
|
190
189
|
return (False, url) if return_url else False
|
191
190
|
|
192
191
|
|
193
|
-
def check_links_in_string(text, verbose=True, return_bad=False, replace=False
|
192
|
+
def check_links_in_string(text, verbose=True, return_bad=False, replace=False):
|
194
193
|
"""Process text, find URLs, check for 404s, and handle replacements with redirects or Brave search."""
|
195
194
|
urls = []
|
196
195
|
for md_text, md_url, plain_url in URL_PATTERN.findall(text):
|
@@ -200,7 +199,8 @@ def check_links_in_string(text, verbose=True, return_bad=False, replace=False, r
|
|
200
199
|
|
201
200
|
with requests.Session() as session, ThreadPoolExecutor(max_workers=64) as executor:
|
202
201
|
session.headers.update(REQUESTS_HEADERS)
|
203
|
-
|
202
|
+
session.cookies = requests.cookies.RequestsCookieJar()
|
203
|
+
results = list(executor.map(lambda x: is_url(x[1], session, return_url=True, redirect=True), urls))
|
204
204
|
bad_urls = [url for (title, url), (valid, redirect) in zip(urls, results) if not valid]
|
205
205
|
|
206
206
|
if replace:
|
@@ -212,14 +212,16 @@ def check_links_in_string(text, verbose=True, return_bad=False, replace=False, r
|
|
212
212
|
for (title, url), (valid, redirect) in zip(urls, results):
|
213
213
|
# Handle invalid URLs with Brave search
|
214
214
|
if not valid and brave_api_key:
|
215
|
-
|
216
|
-
if
|
217
|
-
|
218
|
-
for alt_url in
|
215
|
+
query = f"{(redirect or url)[:200]} {title[:199]}"
|
216
|
+
if search_urls := brave_search(query, brave_api_key, count=3):
|
217
|
+
best_url = search_urls[0]
|
218
|
+
for alt_url in search_urls:
|
219
219
|
if is_url(alt_url, session):
|
220
|
-
|
221
|
-
modified_text = modified_text.replace(url, alt_url)
|
220
|
+
best_url = alt_url
|
222
221
|
break
|
222
|
+
if url != best_url:
|
223
|
+
replacements[url] = best_url
|
224
|
+
modified_text = modified_text.replace(url, best_url)
|
223
225
|
# Handle redirects for valid URLs
|
224
226
|
elif valid and redirect and redirect != url:
|
225
227
|
replacements[url] = redirect
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: ultralytics-actions
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.67
|
4
4
|
Summary: Ultralytics Actions for GitHub automation and PR management.
|
5
5
|
Author-email: Glenn Jocher <glenn.jocher@ultralytics.com>
|
6
6
|
Maintainer-email: Ultralytics <hello@ultralytics.com>
|
@@ -1,15 +1,15 @@
|
|
1
|
-
actions/__init__.py,sha256=
|
1
|
+
actions/__init__.py,sha256=YkxqhvItOspqmgAGHOpRxSY9A4iCKpN5l6_JYyEjSUM,742
|
2
2
|
actions/first_interaction.py,sha256=1_WvQHCi5RWaSfyi49ClF2Zk_3CKGjFnZqz6FlxPRAc,17868
|
3
3
|
actions/summarize_pr.py,sha256=BKttOq-MGaanVaChLU5B1ewKUA8K6S05Cy3FQtyRmxU,11681
|
4
4
|
actions/summarize_release.py,sha256=tov6qsYGC68lfobvkwVyoWZBGtJ598G0m097n4Ydzvo,8472
|
5
5
|
actions/update_markdown_code_blocks.py,sha256=9PL7YIQfApRNAa0que2hYHv7umGZTZoHlblesB0xFj4,8587
|
6
6
|
actions/utils/__init__.py,sha256=XjFyREuhiA7pHfHHBQQqHYKokHhq_px1P9sezk_f1vA,545
|
7
|
-
actions/utils/common_utils.py,sha256=
|
7
|
+
actions/utils/common_utils.py,sha256=tJ0yZl5t_u3BykTdG8F3m4WcypR6uzfGwxPKCgR1wIU,10752
|
8
8
|
actions/utils/github_utils.py,sha256=-F--JgxtXE0fSPMFEzakz7iZilp-vonzLiyXfg0b17Y,7117
|
9
9
|
actions/utils/openai_utils.py,sha256=qQbmrJpOUANxSMf7inDSgPIwgf0JHD1fWZuab-y2W6g,2942
|
10
|
-
ultralytics_actions-0.0.
|
11
|
-
ultralytics_actions-0.0.
|
12
|
-
ultralytics_actions-0.0.
|
13
|
-
ultralytics_actions-0.0.
|
14
|
-
ultralytics_actions-0.0.
|
15
|
-
ultralytics_actions-0.0.
|
10
|
+
ultralytics_actions-0.0.67.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
11
|
+
ultralytics_actions-0.0.67.dist-info/METADATA,sha256=lonA_wg0YB7kD5yMgTgCRsK2mMjLb3Dx0t1cQQ6WzFw,10923
|
12
|
+
ultralytics_actions-0.0.67.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
13
|
+
ultralytics_actions-0.0.67.dist-info/entry_points.txt,sha256=GowvOFplj0C7JmsjbKcbpgLpdf2r921pcaOQkAHWZRA,378
|
14
|
+
ultralytics_actions-0.0.67.dist-info/top_level.txt,sha256=5apM5x80QlJcGbACn1v3fkmIuL1-XQCKcItJre7w7Tw,8
|
15
|
+
ultralytics_actions-0.0.67.dist-info/RECORD,,
|
File without changes
|
{ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/entry_points.txt
RENAMED
File without changes
|
{ultralytics_actions-0.0.65.dist-info → ultralytics_actions-0.0.67.dist-info}/licenses/LICENSE
RENAMED
File without changes
|
File without changes
|