Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
import platform, os, sqlite3 """ Note: Compatible with Python 2.5+, on Darwin 9.7 (OSX 10.5+), Windows XP, Windows Vista, Server 2008, and 7. """ def sqliteClean(sqliteFile): print("Optimizing " + os.path.basename(sqliteFile) + "...") conn = sqlite3.connect(sqliteFile) cursor = conn.cursor() cursor.execute("vacuum") cursor.close() def cleanFolder(profilesPath): for profileFolder in os.listdir(profilesPath): if os.path.isdir(os.path.join(profilesPath, profileFolder)): for dirItem in os.listdir(os.path.join(profilesPath, profileFolder)): if os.path.isfile(os.path.join(profilesPath, profileFolder, dirItem)) and os.path.splitext(dirItem)[1] == ".sqlite": sqliteClean(os.path.join(profilesPath, profileFolder, dirItem)) if platform.system() == "Windows": ffProfile = "Mozilla\Firefox\Profiles" if platform.release() == "XP": cleanFolder(os.path.join(os.environ['APPDATA'], ffProfile)) cleanFolder(os.path.join(os.environ['USERPROFILE'], "Local Settings\Application Data", ffProfile)) if platform.release() == "Vista" or platform.release() == "post2008server": cleanFolder(os.path.join(os.environ['APPDATA'], ffProfile)) cleanFolder(os.path.join(os.environ['LOCALAPPDATA'], ffProfile)) elif platform.system() == "Darwin": ffProfile = "Library/Application Support/Firefox/Profiles" cleanFolder(os.path.join(os.environ['HOME'], ffProfile))
This paste will be private.
From the Design Piracy series on my blog: