Advertisement
Guest User

Untitled

a guest
May 19th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import os, os.path, sys
  2.  
  3. if __name__ == "__main__":
  4.  
  5. scriptlist = [ f for f in os.listdir('.') if f.endswith("ks") ]
  6.  
  7. script = ""
  8. for f in scriptlist:
  9. sfile = open(f, 'r')
  10. script += sfile.read()
  11. sfile.close()
  12.  
  13. wordcount = 0
  14. clickcount = 0
  15. # script = script.decode('utf_16_le')
  16. # script = script.replace(u"\ufeff", "")
  17. script = script.split('\r\n')
  18.  
  19. for line in script:
  20. # if len(line) != 0 and line[0] not in u"*@;":
  21. clickcount += line.count("[pg]")
  22. while line.find("[") >= 0 and line[ line.find("[") + 1] != '[':
  23. a = line.find("[")
  24. b = line.find(']')
  25. while a > b:
  26. b = line.find("]", b+1)
  27. line = line[:a] + line[b+1:]
  28.  
  29. if line.strip() != "":
  30. wordcount += len( line.split() )
  31.  
  32.  
  33. del script
  34.  
  35. result = "This script has %d words." % wordcount
  36. result1 = "\nThis script has %d scenes." % clickcount
  37. print result
  38. print result1
  39.  
  40. lint = open('%d_%d.txt' % (wordcount, clickcount), 'w')
  41. lint.write(result)
  42. lint.write(result1)
  43. lint.close()
  44.  
  45. sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement