File: thumbspage/__sloc__.py
#!/usr/bin/python
"""
A simple, limited-scope source-lines-of-code (a.k.a. sloc) script.
"""
# py 2.X compatibility
from __future__ import print_function
import sys
if sys.version_info[0] == 2: input = raw_input
import os, glob, sys
tally = count = 0
mains = glob.glob('*.py*')
mains += ['template-viewpage.html', # half of the magic is html
'template-floatingtop.html',
'template-autothemes.html',]
print('Main files...')
for fname in sorted(mains): # files in this dir
if not fname.startswith(('__sloc',)): # skip self, keep __init__
fobj = open(fname)
lcnt = len(fobj.readlines())
tally += lcnt
count += 1
print(fname, '=>', lcnt)
print('Total sloc in %d main files: %s\n' % (count, tally))
print('Plus others...')
builds = ['build/_PUBLISH.sh'] + glob.glob('build/*.py')
for fname in builds: # files in build subdir
fobj = open(fname)
lcnt = len(fobj.readlines())
tally += lcnt
count += 1
print(fname, '=>', lcnt)
print('Total sloc in %d files: %s' % (count, tally))
if sys.platform.startswith('win'):
input('Press Enter') # if clicked
"""
================================================================================
Current output (manifest):
Main files...
template-autothemes.html => 96
template-floatingtop.html => 75
template-viewpage.html => 2681
thumbspage.py => 2276
user_configs.py => 1098
viewer_thumbs.py => 887
Total sloc in 6 main files: 7113
Plus others...
build/_PUBLISH.sh => 459
build/generate-examples.py => 107
build/userguide-online-links.py => 163
build/insert-analytics.py => 323
Total sloc in 10 files: 8165
================================================================================
"""