How to use the cssutils.log.setLevel function in cssutils

To help you get started, we’ve selected a few cssutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jorgebastida / glue / tests.py View on Github external
def setUp(self):
        cssutils.log.setLevel(logging.ERROR)
        self.base_path = os.path.dirname(os.path.abspath(__file__))
        self.output_path = os.path.join(self.base_path, self.TEST_PATH)
        shutil.rmtree(self.output_path, True)
        os.makedirs(self.output_path)
        self.pwd = os.getcwd()
        os.chdir(self.output_path)
        sys.stdout = StringIO()
        sys.stderr = StringIO()
github lavr / python-emails / emails / testsuite / loader / test_helpers.py View on Github external
# encoding: utf-8
from __future__ import unicode_literals, print_function

import logging; import  cssutils; cssutils.log.setLevel(logging.FATAL)

from emails.loader.helpers import (guess_charset, guess_text_charset, decode_text, guess_html_charset, RULES_U)


def test_re_rules():
    assert RULES_U.re_is_http_equiv.findall('http-equiv="Content-Type" content="text/html; charset=UTF-8"')


def test_guess_charset():
    assert guess_charset(headers={'content-type': 'text/html; charset=utf-8'}, html='') == 'utf-8'

    assert guess_charset(headers=None, html='') == 'xxx-N'

    html = """"""
    assert guess_charset(headers=None, html=html) == 'UTF-8'
    assert guess_text_charset(html, is_html=True) == 'UTF-8'
github mitmproxy / mitmproxy / mitmproxy / contentviews.py View on Github external
def __call__(self, data, **metadata):
        cssutils.log.setLevel(logging.CRITICAL)
        cssutils.ser.prefs.keepComments = True
        cssutils.ser.prefs.omitLastSemicolon = False
        cssutils.ser.prefs.indentClosingBrace = False
        cssutils.ser.prefs.validOnly = False

        sheet = cssutils.parseString(data)
        beautified = sheet.cssText

        return "CSS", format_text(beautified)
github muicss / flaskapp / flaskapp / __init__.py View on Github external
import pkg_resources

import cssutils
from flask import Flask, g
from flask_wtf import CSRFProtect
from flask_login import current_user
from flask_principal import Principal, UserNeed, identity_loaded

from flaskapp.lib import template_helpers
from flaskapp.meta import mail, db, lm
from flaskapp.models import User
from flaskapp.views import content, auth


# suppress cssutils warning messages
cssutils.log.setLevel(logging.CRITICAL)


# ================================
# App creator method
# ================================
def create_app(extra_config=None):
    """Create Flask app for Flaskapp
    """
    app = Flask('flaskapp',
                template_folder='templates',
                static_folder='static')

    app.config.from_object('config')
    app.config.update(**(extra_config or {}))
    app.before_request(before_request)
github mozilla / spade / spade / utils / cssparser.py View on Github external
"""
Utility to parse and save CSS
"""
import cssutils
import logging
import re

from spade import model

# Ensure that warnings for CSS properties are disabled: cssutils throws
# warnings when properties are not recognized. It also only recognizes up to
# CSS2, and a few CSS3 properties. Most prefixed properties will cause warnings
# We're only using cssutils to iterate over rules, so this is fine
cssutils.log.setLevel(logging.FATAL)


class CSSParser(object):
    def parse_rule(self, rule):
        """
        Returns a tuple containing the rule's selector and parsed properties
        Example: (selector, { property: (prefix, unprefixed_name, value), })
        """
        selector_string = " ".join([s.selectorText for s in rule.selectorList])

        # Get property strings
        properties = []
        for property in rule.style:
            properties.append((property.name, property.value))

        # Create the dictionary that gives us easy access to the components of
github BrainTech / pisak / pisak / css_parser.py View on Github external
import logging
import cssutils

cssutils.log.setLevel(logging.CRITICAL)


class PropsDict(dict):
    '''
    A dictionary with properties.
    Shows properties if no record inside.
    '''
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self._properties = {}

    def __setitem__(self, key, value):
        super().__setitem__(key, value)

    def __repr__(self):
        if self == {}:
github hsoft / pdfmasher / ebooks / oeb / base.py View on Github external
def _parse_css(self, data):
            from cssutils.css import CSSRule
            from cssutils import CSSParser, log
            log.setLevel(logging.WARN)
            def get_style_rules_from_import(import_rule):
                ans = []
                if not import_rule.styleSheet:
                    return ans
                rules = import_rule.styleSheet.cssRules
                for rule in rules:
                    if rule.type == CSSRule.IMPORT_RULE:
                        ans.extend(get_style_rules_from_import(rule))
                    elif rule.type in (CSSRule.FONT_FACE_RULE,
                            CSSRule.STYLE_RULE):
                        ans.append(rule)
                return ans

            logging.debug('Parsing', self.href, '...')
            data = self.oeb.decode(data)
            data = self.oeb.css_preprocessor(data, add_namespace=True)
github pbs / pycaption / pycaption / sami.py View on Github external
from xml.sax.saxutils import escape


from bs4 import BeautifulSoup, NavigableString
from cssutils import parseString, log, css as cssutils_css

from .base import (
    BaseReader, BaseWriter, CaptionSet, CaptionList, Caption, CaptionNode,
    DEFAULT_LANGUAGE_CODE)
from .exceptions import (
    CaptionReadNoCaptions, CaptionReadSyntaxError, InvalidInputError)
from .geometry import Layout, Alignment, Padding, Size


# change cssutils default logging
log.setLevel(FATAL)


SAMI_BASE_MARKUP = '''

    
github Aristotle-Metadata-Enterprises / wcag-zoo / wcag_zoo / validators / molerat.py View on Github external
from __future__ import print_function, division
import webcolors
from xtermcolor import colorize
from wcag_zoo.utils import WCAGCommand, get_applicable_styles, nice_console_text
from decimal import Decimal as D

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

WCAG_LUMINOCITY_RATIO_THRESHOLD = {
    "AA": {
        'normal': 4.5,
        'large': 3,
    },
    "AAA": {
        'normal': 7,
        'large': 4.5,
    }
}

TECHNIQUE = {
    "AA": {
        'normal': "G18",
        'large': "G145",
github kovidgoyal / calibre / src / calibre / ebooks / oeb / iterator / extract_fonts.py View on Github external
def read_font_fule(self, basedir, css):
        from PyQt5.Qt import QFontDatabase
        import cssutils
        cssutils.log.setLevel(logging.ERROR)
        try:
            sheet = cssutils.parseString(css, validate=False)
        except:
            return
        for rule in sheet.cssRules:
            try:
                s = rule.style
                src = s.getProperty('src').propertyValue[0].uri
                font_family = s.getProperty('font-family').propertyValue[0].value
            except:
                continue
            if not src or not font_family:
                continue
            font_file = os.path.normcase(os.path.abspath(os.path.join(basedir,
                src)))
            if font_file not in self.added_fonts: