2014-12-19 11:35:00 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2014-12-31 14:22:46 +01:00
|
|
|
excludes = ['istats_diff.py']
|
|
|
|
|
2014-12-19 11:35:00 +01:00
|
|
|
filename = sys.argv[1]
|
2014-12-31 14:52:14 +01:00
|
|
|
printName = False
|
|
|
|
|
|
|
|
if filename == '-p':
|
|
|
|
filename = sys.argv[2]
|
|
|
|
printName = True
|
2014-12-19 11:35:00 +01:00
|
|
|
|
|
|
|
if filename.endswith('__init__.py'):
|
|
|
|
sys.exit(0)
|
|
|
|
|
2014-12-31 14:22:46 +01:00
|
|
|
for e in excludes:
|
|
|
|
if filename.endswith(e):
|
|
|
|
sys.stderr.write('\tSkip %s\n' % (filename))
|
|
|
|
sys.exit(0)
|
|
|
|
|
2014-12-31 14:52:14 +01:00
|
|
|
if printName:
|
|
|
|
sys.stdout.write(' * %s\n' % (filename))
|
|
|
|
sys.exit(0)
|
|
|
|
|
2014-12-19 11:35:00 +01:00
|
|
|
package_name = filename.replace('/', '.').replace('.py', '')
|
2014-12-19 17:21:45 +01:00
|
|
|
sys.stdout.write('%s' % (package_name))
|
|
|
|
sys.stdout.write('\n')
|
2014-12-19 11:35:00 +01:00
|
|
|
# sys.stdout.write('\n\n')
|
2014-12-19 17:21:45 +01:00
|
|
|
sys.stdout.write('-' * len(package_name))
|
|
|
|
sys.stdout.write('\n\n')
|
2014-12-19 11:35:00 +01:00
|
|
|
|
|
|
|
sys.stderr.write('\tExtract doc from %s\n' % (filename))
|
|
|
|
|
|
|
|
with open(filename) as infile:
|
|
|
|
copy = False
|
|
|
|
for line in infile:
|
|
|
|
if line.strip() in ['"""', "'''"]:
|
|
|
|
if not copy:
|
|
|
|
copy = True
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
elif copy:
|
2014-12-19 17:21:45 +01:00
|
|
|
sys.stdout.write(' %s' % (line))
|
2014-12-19 11:35:00 +01:00
|
|
|
|
|
|
|
sys.stdout.write('\n\n')
|