srcexts [py'pyw'cgi'html' 'cxx' ' 'if __name__ ='__main__'walker sourcelines(walker run(sys argv[ ]print('visited % files and % dirs(walker fcountwalker dcount)print('-'* print('source files=>%dlines=>% (walker srcfileswalker srclines)print('by types:'pprint pprint(walker extsumsprint('\ncheck sums:'end='print(sum( ['lines'for in walker extsums values())end='print(sum( ['files'for in walker extsums values())print('\npython only walk:'walker pylines(trace= walker run(sys argv[ ]pprint pprint(walker extsumswhen run as scriptwe get trace messages during the walk (omitted here to save space)and report with line counts grouped by file type run this on trees of your own to watch its progressmy tree has source files and source linesincluding files and lines of pypython codec:\pp \toolsvisitor_sloc py :\temp\pp \examples visited files and dirs source files=> lines=> by types{ '{'files' 'lines' }cgi'{'files' 'lines' }cxx'{'files' 'lines' } '{'files' 'lines' }html'{'files' 'lines' } '{'files' 'lines' }py'{'files' 'lines' }pyw'{'files' 'lines' }check sums python only walk{py'{'files' 'lines' }pyw'{'files' 'lines' }recoding copies with classes (visitorlet' peek at one more visitor use case when first wrote the cpall py script earlier in this couldn' see way that the visitor class hierarchy we met earlier would help two directories needed to be traversed in parallel (the original and the copy)and visitor is based on walking just one tree with os walk there seemed no easy way to keep track of where the script was in the copy directory visitorwalking directories "++