-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudit_triangles.py
More file actions
57 lines (51 loc) · 1.96 KB
/
audit_triangles.py
File metadata and controls
57 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
from bs4 import BeautifulSoup
# Define clusters
CLUSTERS = [
{
"name": "OLED Monitors",
"A": "posts/alienware-aw3423dwf-review.html",
"B": "posts/samsung-odyssey-g8-review.html",
"Bridge": "posts/samsung-odyssey-g8-vs-alienware-aw3423dwf.html"
},
{
"name": "Pro Audio",
"A": "posts/shure-sm7b-review.html",
"B": "posts/shure-sm7db-review.html",
"Bridge": "posts/shure-sm7b-vs-sm7db.html"
},
{
"name": "Noise Cancelling",
"A": "posts/sony-wh-1000xm5-review.html",
"B": "posts/bose-qc-ultra-review.html",
"Bridge": "posts/sony-xm5-vs-bose-qc-ultra.html"
}
]
def check_link(source_file, target_file):
if not os.path.exists(source_file):
return f"MISSING FILE: {source_file}"
with open(source_file, 'r', encoding='utf-8') as f:
soup = BeautifulSoup(f, 'html.parser')
links = [a.get('href') for a in soup.find_all('a', href=True)]
# Check for both relative and root-relative links
target_name = os.path.basename(target_file)
for link in links:
if target_name in link:
return "CONNECTED"
return "DISCONNECTED"
print(f"{'Cluster':<20} | {'Link Direction':<25} | {'Status'}")
print("-" * 60)
for c in CLUSTERS:
# A -> Bridge
print(f"{c['name']:<20} | {'A -> Bridge':<25} | {check_link(c['A'], c['Bridge'])}")
# B -> Bridge
print(f"{c['name']:<20} | {'B -> Bridge':<25} | {check_link(c['B'], c['Bridge'])}")
# Bridge -> A
print(f"{c['name']:<20} | {'Bridge -> A':<25} | {check_link(c['Bridge'], c['A'])}")
# Bridge -> B
print(f"{c['name']:<20} | {'Bridge -> B':<25} | {check_link(c['Bridge'], c['B'])}")
# A -> B (Optional but good)
print(f"{c['name']:<20} | {'A -> B':<25} | {check_link(c['A'], c['B'])}")
# B -> A (Optional but good)
print(f"{c['name']:<20} | {'B -> A':<25} | {check_link(c['B'], c['A'])}")
print("-" * 60)