Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import os
  2. cur_path = os.getcwd()
  3. ignore_set = set(["__init__.py", "count_sourcelines.py"])
  4.  
  5. loclist = []
  6.  
  7. for pydir, _, pyfiles in os.walk(cur_path):
  8.     for pyfile in pyfiles:
  9.         if pyfile.endswith(".py") and pyfile not in ignore_set:
  10.             totalpath = os.path.join(pydir, pyfile)
  11.             loclist.append( ( len(open(totalpath, "r").read().splitlines()),
  12.                                totalpath.split(cur_path)[1]) )
  13.  
  14. for linenumbercount, filename in loclist:
  15.     print "%05d lines in %s" % (linenumbercount, filename)
  16.  
  17. print "\nTotal: %s lines (%s)" %(sum([x[0] for x in loclist]), cur_path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement