~testdoc-dev/testdoc/trunk.git

« back to all changes in this revision

Viewing changes to bin/testdoc

  • Committer: jml@canonical.com
  • Date: 2007-03-31 06:06:47 UTC
  • Revision ID: git-v1:8616dba4a3b0a3f8eb750e2cd2d558e8ab3be748
Add a setup.py file and accept filenames on the command line.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
 
3
import inspect
 
4
import os
3
5
import sys
4
6
import testdoc
5
7
from testdoc import documenter, finder, formatter, reflect
9
11
    return "Usage: testdoc <fully-qualified module name>"
10
12
 
11
13
 
 
14
def string_to_module(argument):
 
15
    if os.path.exists(argument):
 
16
        return reflect.filenameToModule(argument)
 
17
    obj = reflect.namedAny(argument)
 
18
    if not inspect.ismodule(obj):
 
19
        raise ValueError('%r is not a Python module' % (argument,))
 
20
 
 
21
 
12
22
def main():
13
23
    if len(sys.argv) != 2:
14
24
        print usage()
15
25
        sys.exit(2)
16
26
    try:
17
 
        module = reflect.namedAny(sys.argv[1])
 
27
        module = string_to_module(sys.argv[1])
18
28
    except:
19
29
        print usage()
20
30
        raise