Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
#!/usr/bin/python -S import re import sys from os import environ as env sys.path.insert(0, env["TM_SUPPORT_PATH"] + "/lib") import webpreview content = sys.stdin.read() if "TM_SWEAR_WORDS" in env: swear_words = env["TM_SWEAR_WORDS"].split(":") else: swear_words = ["foo", "bar", "baz"] swear_counts = {} for word in swear_words: matches = re.findall(r"%s" % word, content, re.M) print matches swear_counts[word] = len(matches) print webpreview.html_header("SwearCount", "") print "<table>" for word in swear_counts.keys(): print "<tr><td>%s</td><td>%i</td></tr>" % (word, swear_counts[word]) print "</table>" print webpreview.html_footer()
This paste will be private.
From the Design Piracy series on my blog: