Created
February 27, 2012 15:28
-
-
Save xulapp/1924663 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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