MCPcopy Index your code
hub / github.com/modelscope/ms-swift / check_links_in_folder

Function check_links_in_folder

scripts/utils/test_link_valid.py:25–52  ·  view source on GitHub ↗
(folder_path)

Source from the content-addressed store, hash-verified

23
24
25def check_links_in_folder(folder_path):
26 for root, _, files in os.walk(folder_path):
27 for file in files:
28 if file.endswith('.md'):
29 if file in ['Supported-models-and-datasets.md', 'Supported-models-and-datasets.md']:
30 continue
31 file_path = os.path.join(root, file)
32 logger.info(f'Checking links in file: {file_path}')
33 links = extract_links_from_md(file_path)
34 for link in links:
35 if not link.startswith(('http://', 'https://')):
36 path = link.rsplit('#', 1)[0]
37 if path:
38 path = os.path.abspath(os.path.join(root, path))
39 if os.path.exists(path):
40 logger.info(f'✅ Link is valid: {link}')
41 else:
42 logger.info(f'❌ Link is broken: {link}')
43 else:
44 logger.info(f'Skipping non-HTTP link: {link}')
45 continue
46 if check_link(link):
47 logger.info(f'✅ Link is valid: {link}')
48 else:
49 if 'huggingface.co' in link:
50 logger.info(f'Link is broken: {link}')
51 else:
52 logger.info(f'❌ Link is broken: {link}')
53
54
55if __name__ == '__main__':

Callers 1

test_link_valid.pyFile · 0.85

Calls 2

extract_links_from_mdFunction · 0.85
check_linkFunction · 0.85

Tested by

no test coverage detected