How to use the premailer.cache.function_cache function in premailer

To help you get started, we’ve selected a few premailer 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 peterbe / premailer / premailer / merge_style.py View on Github external
@function_cache()
def csstext_to_pairs(csstext, validate=True):
    """
    csstext_to_pairs takes css text and make it to list of
    tuple of key,value.
    """
    # The lock is required to avoid ``cssutils`` concurrency
    # issues documented in issue #65
    with csstext_to_pairs._lock:
        return sorted(
            [
                (prop.name.strip(), format_value(prop))
                for prop in cssutils.parseStyle(csstext, validate=validate)
            ],
            key=itemgetter(0),
        )
github peterbe / premailer / premailer / premailer.py View on Github external
@function_cache()
def _create_cssselector(selector):
    return CSSSelector(selector)
github liuwons / EverMark / premailer / premailer.py View on Github external
@function_cache()
def _cache_parse_css_string(css_body, validate=True):
    """
        This function will cache the result from cssutils
        It is a big gain when number of rules is big
        Maximum cache entries are 1000. This is mainly for
        protecting memory leak in case something gone wild.
        Be aware that you can turn the cache off in Premailer

        Args:
            css_body(str): css rules in string format
            validate(bool): if cssutils should validate

        Returns:
            cssutils.css.cssstylesheet.CSSStyleSheet

    """
github peterbe / premailer / premailer / premailer.py View on Github external
@function_cache()
def _cache_parse_css_string(css_body, validate=True):
    """
        This function will cache the result from cssutils
        It is a big gain when number of rules is big
        Maximum cache entries are 1000. This is mainly for
        protecting memory leak in case something gone wild.
        Be aware that you can turn the cache off in Premailer

        Args:
            css_body(str): css rules in string format
            validate(bool): if cssutils should validate

        Returns:
            cssutils.css.cssstylesheet.CSSStyleSheet

    """