Ticket #15233: modulecheck.py

File modulecheck.py, 810 bytes (added by Aryeh Leib Taurog <vim@…>, 5 years ago)

script to check module paths of objects in documentation index

Line 
1#!/usr/bin/python
2"""
3django must be installed
4execute this script in a functioning django environment
5* Make sure DJANGO_SETTINGS_MODULE environment var is set
6* Make sure the module to which it points is on python path
7
8Then run this script on genindex.html
9
10Take results with grain of salt; not all objects documented are meant to be imported directly
11"""
12
13import fileinput
14import re
15
16module_re = re.compile(r'href="(.*\.html)#django\.[\w.]+">(\w+)(?:\(\) \(in module| \(class in) (django\.[\w.]+)\)')
17for line in fileinput.input():
18    match = module_re.search(line)
19    if match:
20        html, obj, mod = match.groups()
21        try:
22            m = __import__(mod, fromlist=[obj])
23            getattr(m, obj)
24        except (ImportError, AttributeError):
25            print "%s, %s, %s" % (html, mod, obj)
Back to Top