#!/usr/bin/python ######################################################################## # # Copyright 2002, Tero Tilus  # # This software is distributed under the terms of the GNU general # Public license  and WITHOUT # ANY WARRANTY. # ######################################################################## # Takes list of css -files as arguments. Prints sorted combination of # files with duplicate css-entries removed. Only string-comparison is # made between entries, so css-files MUST have same (canonical) # format. If they don't a css pretty-printter (if you can find one) # may help. import sys import string def main(args): cssfiles = args[1:] if ( len(cssfiles) < 1 ): print 'Usage: ' + (string.split(args[0],'/')[-1]) + \ ' file1.css [file2.css ...]' return 1 entries = [] for cssfilename in cssfiles: cssfile = open(cssfilename, 'r') tmpentries = string.split(cssfile.read(), '}') for tmpentry in tmpentries: tmpentry = string.strip(tmpentry)+'\012}' if ( entries.count(tmpentry) == 0 ): entries.append(tmpentry) cssfile.close() entries.sort() for entry in entries: print entry+'\012'; return 0 main(sys.argv)