(folder_path)
| 23 | |
| 24 | |
| 25 | def 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 | |
| 55 | if __name__ == '__main__': |
no test coverage detected