old_contents: from __future__ import absolute_import
  import logging
  import logging.handlers
  
  from webassets.filter import Filter
  
  
  __all__ = ('CSSUtils',)
  
  
  class CSSUtils(Filter):
      """Minifies CSS by removing whitespace, comments etc., using the Python
      `cssutils <http://cthedot.de/cssutils/>`_ library.
  
      Note that since this works as a parser on the syntax level, so invalid
      CSS input could potentially result in data loss.
      """
  
      name = 'cssutils'
  
      def setup(self):
          import cssutils
          self.cssutils = cssutils
  
          try:
              log = logging.getLogger('assets.cssutils')
              log.addHandler(logging.handlers.MemoryHandler(10))
  
              # Newer versions of cssutils print a deprecation warning
              # for 'setlog'.
              if hasattr(cssutils.log, 'setLog'):
                  func = cssutils.log.setLog
              else:
                  func = cssutils.log.setlog
              func(log)
              
              # cssutils is unaware of so many new CSS3 properties,
              # vendor-prefixes etc., that it's diagnostic messages are rather
              # useless. Disable them.
              cssutils.log.setLevel(logging.FATAL)
          except ImportError:
              # During doc generation, Django is not going to be setup and will
              # fail when the settings object is accessed. That's ok though.
              pass
  
      def output(self, _in, out, **kw):
          sheet = self.cssutils.parseString(_in.read())
          self.cssutils.ser.prefs.useMinified()
          out.write(sheet.cssText.decode('utf-8'))
  
new_contents: from __future__ import absolute_import
  import logging
  import logging.handlers
  
  from webassets.filter import Filter
  
  
  __all__ = ('CSSUtils',)
  
  
  class CSSUtils(Filter):
      """Minifies CSS by removing whitespace, comments etc., using the Python
      `cssutils <http://cthedot.de/cssutils/>`_ library.
  
      Note that since this works as a parser on the syntax level, so invalid
      CSS input could potentially result in data loss.
      """
  
      name = 'cssutils'
  
      def setup(self):
          import cssutils
          self.cssutils = cssutils
  
          # cssutils is unaware of many new CSS3 properties,
          # vendor-prefixes etc., and logs many non-fatal warnings
          # about them. These diagnostic messages are rather
          # useless, so disable everything that's non-fatal.
          cssutils.log.setLevel(logging.FATAL)
  
      def output(self, _in, out, **kw):
          sheet = self.cssutils.parseString(_in.read())
          self.cssutils.ser.prefs.useMinified()
          out.write(sheet.cssText.decode('utf-8'))
  
subject: refactor cssutils filter initalization remove try/except ImportError and change workaround for silencing cssutils * The try/except ImportError is not needed anymore as neither a django settings object is accessed nor an import is taking place. * The setLog / setlog deprecation workaround is not needed anymore because even Debian wheezy ships a newer version of cssutils. * Raising the log level to fatal is enough to hide all of cssutil's warnings encountering CSS3.