Skip to content

Commit

Permalink
scripts to test ofind dead links in urls provided in binding docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
foutoucour committed May 31, 2014
1 parent 4c9c58f commit 323a136
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bindings_url_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
""" script to parse the url of bindings and find if the page exists or not """
import pprint
import re
import os
import requests

__author__ = 'jordiriera'

url_root = 'https://dev.twitter.com'
reference_line = re.compile(':reference: ({}.*) "'.format(url_root))


def parse(filename):
dead_links = []
with open(filename, 'r') as file_:
for line in file_.readlines():
res = reference_line.search(line)
if res:
if not exists(res.group(1)):
dead_links.append(res.group(1))

return dead_links


def exists(path):
r = requests.head(path)
return r.status_code == requests.codes.ok


if __name__ == '__main__':
root = os.path.dirname(os.path.abspath(__file__))
filename = os.path.join(root, 'tweepy', 'api.py')
pprint.pprint(parse(filename))

0 comments on commit 323a136

Please sign in to comment.