Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop cssutils from generating warning messages

Tags:

python

css

I am using the parseFile convenience method to read a css file but it is generating a huge amount of warning messages.
I have set validate=False but it is still printing the messages.
I have tried to create a CSSParser object and initialising the log object and logging level to none but it is still printing warnings and errors.
I looked in the source code and couldn't see where these message are being created so it might be in something that parseFile calls.

Is there any way of stopping the CSSParser.parseFile() from generating message like the ones below?

 WARNING CSSStylesheet: Unknown @rule found. [3:43150:@-webkit-keyframes] 
 WARNING    CSSStylesheet: Unknown @rule found. [3:43329: @-moz-keyframes] 
 WARNING    CSSStylesheet: Unknown @rule found. [3:43496: @keyframes]
 WARNING    CSSStylesheet: Unknown @rule found. [3:43643: @-webkit-keyframes] 
 WARNING    Property: Unknown Property name. [3:79871: min-device-width]
 WARNING    Property: Unknown Property name. [3:79900: max-device-width] 
 ERROR  MediaQuery: Unexpected syntax, expected "and" but found "(". [3:86572: (]
 ERROR  MediaQuery: Unexpected syntax, expected "and" but found ":". [3:86582: :]
 ERROR  MediaQuery: Unexpected syntax. [3:86583: 35em]
 ERROR  MediaQuery: Unexpected syntax, expected "and" but found ")". [3:86587: )]

Any help would be greatly appreciated!

like image 395
jonathanbyrn Avatar asked Dec 04 '13 09:12

jonathanbyrn


1 Answers

The logger is a singleton, so, put this line above your instruction

import logging
cssutils.log.setLevel(logging.CRITICAL)

This disables the warning and error logging.

like image 149
Felix Carmona Avatar answered Oct 17 '22 03:10

Felix Carmona