File: pymailgui-products/unzipped/__sloc__.py

#!/usr/bin/python3
"""
simple source-code line count script, used for dev metrics only [4.0]
"""
import os, glob, sys
srcenc = 'utf8'                                 # allow for Unicode source files

def collect(paths):
    manifest = []
    for path in paths:
        manifest += glob.glob(path.replace('/', os.sep))
    return manifest

# the basics 
sources = ('*.py', '*.pyw',             # top-level launchers here
           'MailConfigs/*.py',          # per-account configs here
           'PyMailGui-PP4E/*.py',       # PyMailGUI's own files
           )

# imported tools from PP4E, many updated much for 4.0
sources += (
           'PyMailGui-PP4E/PP4E/Internet/Email/mailtools/mailFetcher.py',
           'PyMailGui-PP4E/PP4E/Internet/Email/mailtools/mailSender.py',
           'PyMailGui-PP4E/PP4E/Internet/Email/mailtools/mailParser.py',
           'PyMailGui-PP4E/PP4E/Gui/Tools/threadtools.py',
           'PyMailGui-PP4E/PP4E/Gui/Tools/windows.py',
           'PyMailGui-PP4E/PP4E/Gui/Tools/guimaker.py',
           'PyMailGui-PP4E/PP4E/Gui/TextEditor/textEditor.py',   # really, *.py
           'PyMailGui-PP4E/PP4E/Gui/TextEditor/textConfig.py',
           'PyMailGui-PP4E/PP4E/Gui/ShellGui/formrows.py',
           'PyMailGui-PP4E/PP4E/Gui/Tour/scrolledlist.py',
           'PyMailGui-PP4E/PP4E/Tools/find.py',
           'PyMailGui-PP4E/PP4E/launchmodes.py'
           )

# app/exe build scripts count too (but skip iconify.py)
sources += ('build/build-app-exe/*/build.py',)
sources += ('build/build-source/build.py',)
                    
tally = count = 0
for fname in collect(sources):                   # used files in this tree
    if not fname.startswith('__'):               # skip self and extras in '.'
        fobj = open(fname, encoding=srcenc)      # else do os.path.basename()
        lcnt = len(fobj.readlines())
        tally += lcnt
        count += 1
        print(fname, '=>', lcnt)
        
print('Total sloc in {} files: {:,d}'.format(count, tally))     # now 5 digits!
if sys.platform.startswith('win'):
    input('Press Enter')  # if clicked on Windows


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

fixfrozenpaths.py => 107
Launch_PyMailGUI.py => 287
Launch_PyEdit.pyw => 73
MailConfigs/mailconfig_defaultbase.py => 15
MailConfigs/mailconfig_Gmail.py => 124
MailConfigs/mailconfig_LearningPython.py => 109
MailConfigs/mailconfig_LearningPython_ssl.py => 34
MailConfigs/mailconfig_Lutzmv.py => 107
MailConfigs/mailconfig_Lutzmv_ssl.py => 37
MailConfigs/mailconfig_Lutzmv_ssl_mail.py => 32
MailConfigs/mailconfig_Lutzmv_ssl_spam.py => 33
MailConfigs/mailconfig_RmiDotNet.py => 108
MailConfigs/mailconfig_RmiDotNet_ssl.py => 27
MailConfigs/mailconfig_testerrors.py => 30
PyMailGui-PP4E/__init__.py => 14
PyMailGui-PP4E/fixfrozenpaths.py => 99
PyMailGui-PP4E/fixTkBMP.py => 92
PyMailGui-PP4E/html2text.py => 93
PyMailGui-PP4E/ListWindows.py => 1191
PyMailGui-PP4E/mailconfig.py => 507
PyMailGui-PP4E/messagecache.py => 181
PyMailGui-PP4E/popuputil.py => 121
PyMailGui-PP4E/py33patch.py => 179
PyMailGui-PP4E/PyMailGui.py => 286
PyMailGui-PP4E/PyMailGuiHelp.py => 774
PyMailGui-PP4E/SharedNames.py => 88
PyMailGui-PP4E/textConfig.py => 172
PyMailGui-PP4E/ViewWindows.py => 905
PyMailGui-PP4E/wraplines.py => 109
PyMailGui-PP4E/PP4E/Internet/Email/mailtools/mailFetcher.py => 426
PyMailGui-PP4E/PP4E/Internet/Email/mailtools/mailSender.py => 398
PyMailGui-PP4E/PP4E/Internet/Email/mailtools/mailParser.py => 328
PyMailGui-PP4E/PP4E/Gui/Tools/threadtools.py => 163
PyMailGui-PP4E/PP4E/Gui/Tools/windows.py => 181
PyMailGui-PP4E/PP4E/Gui/Tools/guimaker.py => 667
PyMailGui-PP4E/PP4E/Gui/TextEditor/textEditor.py => 5105
PyMailGui-PP4E/PP4E/Gui/TextEditor/textConfig.py => 642
PyMailGui-PP4E/PP4E/Gui/ShellGui/formrows.py => 60
PyMailGui-PP4E/PP4E/Gui/Tour/scrolledlist.py => 62
PyMailGui-PP4E/PP4E/Tools/find.py => 32
PyMailGui-PP4E/PP4E/launchmodes.py => 629
build/build-app-exe/linux/build.py => 324
build/build-app-exe/macosx/build.py => 271
build/build-app-exe/windows/build.py => 352
build/build-source/build.py => 132
Total sloc in 45 files: 15,706
================================================================================
"""



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