File: mergeall-products/unzipped/__sloc__.py

#!/usr/bin/python
"simple limited-scope source-code line count 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

# 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
globpath = lambda *args: glob.glob(os.path.join(*args))
extras = (globpath('test', '*.py') +
          globpath('test', 'ziptools', '*.py') +
          globpath('test', 'ziptools', 'ziptools', '*.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')

for fname in glob.glob('*.py*') + extras:         # files in this dir (mostly) 
    if not fname.startswith('__'):                # skip self and extras in '.'
        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):

autoflush.py => 46
backup.py => 849
cpall.py => 564
diffall.py => 384
dirdiff.py => 80
fix-fat-dst-modtimes.py => 134
fixfrozenpaths.py => 119
fixlongpaths.py => 486
guimaker_pp4e.py => 113
launch-mergeall-Console.py => 378
launch-mergeall-GUI.pyw => 1292
mergeall.py => 1699
mergeall_configs.py => 403
nuke-cruft-files.py => 632
rollback.py => 159
scandir_defunct.py => 320
skipcruft.py => 134
test/test-1-2-do-unzip.py => 23
test/test-1-2-do-zip.py => 21
test/ziptools/__init__.py => 1
test/ziptools/__sloc__.py => 42
test/ziptools/selftest.py => 95
test/ziptools/zip-create.py => 218
test/ziptools/zip-extract.py => 148
test/ziptools/zip-list.py => 39
test/ziptools/ziptools/__init__.py => 3
test/ziptools/ziptools/zipcruft.py => 36
test/ziptools/ziptools/ziplongpaths.py => 98
test/ziptools/ziptools/zipsymlinks.py => 245
test/ziptools/ziptools/ziptools.py => 725
build/build-app-exe/linux/build.py => 190
build/build-app-exe/macosx/build.py => 207
build/build-app-exe/windows/build.py => 217
build/build-source/build.py => 101
Total sloc in 34 files: 10201
================================================================================
"""



[Home] Books Programs Blog Python Author Training Search Email ©M.Lutz