Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created February 27, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xulapp/1924663 to your computer and use it in GitHub Desktop.
Save xulapp/1924663 to your computer and use it in GitHub Desktop.
# coding: utf-8
import sys
import os
class NullDevice:
def write(self, s):
pass
_stderr = sys.stderr
sys.stderr = NullDevice()
import cssutils
sys.stderr = _stderr
max_count = 4095
def main(args):
if len(args) < 1 or not os.path.isfile(args[0]):
return
sheet = cssutils.parseFile(args[0], validate=False)
count = 0
for rule in sheet:
if rule.type == rule.STYLE_RULE:
count += len(rule.selectorList)
print '%d selectors (max: %d)' % (count, max_count)
if max_count < count:
print '%d over' % (count - max_count)
if __name__ == '__main__':
main(sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment