(path)
| 40 | |
| 41 | |
| 42 | def main(path): |
| 43 | |
| 44 | filenames = [] |
| 45 | for (dirpath, dnames, fnames) in os.walk(path): |
| 46 | for fname in fnames: |
| 47 | if fname.endswith('.md'): |
| 48 | filenames.append(os.sep.join([dirpath, fname])) |
| 49 | |
| 50 | urls = [] |
| 51 | |
| 52 | for filename in filenames: |
| 53 | fd = codecs.open(filename, mode="r", encoding="utf-8") |
| 54 | for line in fd.readlines(): |
| 55 | refs = re.findall(r'(?<=<a href=")[^"]*', markdown.markdown(line)) |
| 56 | for ref in refs: |
| 57 | if ref not in urls: |
| 58 | urls.append(ref) |
| 59 | fd.close() |
| 60 | |
| 61 | for url in urls: |
| 62 | if not url.startswith("http"): |
| 63 | print("markdown file name: " + url) |
| 64 | continue |
| 65 | if check_live_url(url): |
| 66 | print(url) |
| 67 | else: |
| 68 | print(url, file=sys.stderr) |
| 69 | |
| 70 | |
| 71 | if __name__ == '__main__': |
no test coverage detected