File: mergeall-products/unzipped/__sloc__.py

#!/usr/bin/python
"""
A simple limited-scope source-code line count (a.k.a. sloc) script.
See UserGuide.html for license, attribution, and other logistics.
"""

# 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

# other examples in this tree unique to mergeall [3.0]
# CAVEAT: ziptools is now released separately, but its code 
# is still counted here for comparability to older releases;
# as of Oct22, ziptools is 3500 lines among 14 source files

globpath = lambda *args: glob.glob(os.path.join(*args))

extras = (['_publish.sh', 'docetc/docimgs/_publish.sh'] + 
          globpath('test', '*.py') +
          globpath('test', 'ziptools', '*.py') +
          globpath('test', 'ziptools', 'ziptools', '*.py') +
          globpath('test', 'test-normalization-3.3', '*', '_TEST.py') +
          globpath('test', 'test-path-normalization-3.3', '*', '*.py') +
          globpath('docetc', 'Tools', '*.py')
          )

# app/exe build scripts count too (but skip iconify.py)
extras += globpath('build', 'build-app-exe', '*', 'build.py')
extras += globpath('build', 'build-source', 'build.py')

# don't use '*.py*': includes 2.X .pyc's 
mains = glob.glob('*.py') + glob.glob('*.pyw')

# skip 415-line mergeall.py-devdocs.txt, moved in 3.3

for fname in sorted(mains) + sorted(extras):     # files in this dir + others 
    if not fname.startswith('__sloc'):           # skip self in '.' and ziptools
        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


"""
================================================================================
Example output (current counts/manifest):

__version__.py => 7
autoflush.py => 46
backup.py => 1051
cpall.py => 659
deltas.py => 869
diffall.py => 449
dirdiff.py => 134
fix-fat-dst-modtimes.py => 136
fix-nonportable-filenames.py => 238
fixfrozenpaths.py => 119
fixlongpaths.py => 486
fixunicodedups.py => 741
guimaker_pp4e.py => 113
launch-mergeall-Console.py => 387
launch-mergeall-GUI.pyw => 1393
mergeall.py => 1717
mergeall_configs.py => 416
nuke-cruft-files.py => 632
rollback.py => 161
scandir_defunct.py => 320
skipcruft.py => 134
_publish.sh => 168
build/build-app-exe/linux/build.py => 212
build/build-app-exe/macosx/build.py => 222
build/build-app-exe/windows/build.py => 262
build/build-source/build.py => 137
docetc/Tools/fixeoln-all.py => 252
docetc/Tools/fixeoln.py => 210
docetc/Tools/ls.py => 41
docetc/Tools/pickcolor.py => 83
docetc/Tools/post-diffall-auto-compare.py => 36
docetc/docimgs/_publish.sh => 63
test/test-1-2-do-unzip.py => 23
test/test-1-2-do-zip.py => 21
test/test-normalization-3.3/Normalization/_TEST.py => 162
test/test-normalization-3.3/SameVersus3.2/_TEST.py => 63
test/test-path-normalization-3.3/prototype-recoding-oct22/py-split-join.py => 205
test/test-path-normalization-3.3/test-path-normalization-walks/_TEST.py => 315
test/ziptools/__init__.py => 1
test/ziptools/__sloc__.py => 52
test/ziptools/__version__.py => 9
test/ziptools/fix-nonportable-filenames.py => 238
test/ziptools/selftest.py => 109
test/ziptools/zip-create.py => 389
test/ziptools/zip-extract.py => 297
test/ziptools/zip-list.py => 50
test/ziptools/ziptools/__init__.py => 3
test/ziptools/ziptools/zipcruft.py => 105
test/ziptools/ziptools/ziplongpaths.py => 102
test/ziptools/ziptools/zipmodtimeutc.py => 199
test/ziptools/ziptools/zipsymlinks.py => 402
test/ziptools/ziptools/ziptools.py => 1482
Total sloc in 52 files: 16121

================================================================================
"""



[Home page] Books Code Blog Python Author Train Find ©M.Lutz