How to use the premailer.premailer.ExternalNotFoundError 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 / test_premailer.py View on Github external
<h1>Hello</h1>
        <h2>World</h2>
        <h3>Test</h3>
        <a href="#">Link</a>
        
        """

        p = Premailer(
            html,
            strip_important=False
        )
        assert_raises(
            ExternalNotFoundError,
            p.transform,
        )
github Aristotle-Metadata-Enterprises / wcag-zoo / wcag_zoo / utils.py View on Github external
if not os.path.isabs(stylefile):
                stylefile = os.path.abspath(
                    os.path.join(self.base_path or '', stylefile)
                )
            elif os.path.isabs(stylefile):  # &lt;--- This is the if branch we added
                stylefile = os.path.abspath(
                    os.path.join(self.base_path or '', stylefile[1:])
                )
            if os.path.exists(stylefile):
                with codecs.open(stylefile, encoding='utf-8') as f:
                    css_body = f.read()
            elif self.base_url:
                url = urljoin(self.base_url, url)
                return self._load_external(url)
            else:
                raise ExternalNotFoundError(stylefile)

        return css_body
github peterbe / premailer / premailer / premailer.py View on Github external
if url.startswith("http://") or url.startswith("https://"):
            css_body = self._load_external_url(url)
        else:
            stylefile = url
            if not os.path.isabs(stylefile):
                stylefile = os.path.abspath(
                    os.path.join(self.base_path or "", stylefile)
                )
            if os.path.exists(stylefile):
                with codecs.open(stylefile, encoding="utf-8") as f:
                    css_body = f.read()
            elif self.base_url:
                url = urljoin(self.base_url, url)
                return self._load_external(url)
            else:
                raise ExternalNotFoundError(stylefile)

        return css_body
github lavr / python-emails / emails / transformer.py View on Github external
if url.startswith('http://') or url.startswith('https://'):
            content = self._load_external_url(url)
        else:
            content = None

            if self.local_loader:
                try:
                    content = self.local_loader[url]
                except FileNotFound:
                    content = None

            if content is None:
                if self.base_url:
                    return self._load_external(urlparse.urljoin(self.base_url, url))
                else:
                    raise ExternalNotFoundError(url)

        return content
github liuwons / EverMark / premailer / premailer.py View on Github external
if url.startswith('http://') or url.startswith('https://'):
            css_body = self._load_external_url(url)
        else:
            stylefile = url
            if not os.path.isabs(stylefile):
                stylefile = os.path.abspath(
                    os.path.join(self.base_path or '', stylefile)
                )
            if os.path.exists(stylefile):
                with codecs.open(stylefile, encoding='utf-8') as f:
                    css_body = f.read()
            elif self.base_url:
                url = urljoin(self.base_url, url)
                return self._load_external(url)
            else:
                raise ExternalNotFoundError(stylefile)

        return css_body
github turkus / live-premailer / lpremailer / exceptions.py View on Github external
please revert your last change, hope that helps :)
    """


class LiveJSONDecodeError(LiveBaseError):
    MSG = 'Your json file is invalid:'

    def live_message(self):
        msg = '\n{}\n{}\n{}: line {} column {} char({})\n'
        return msg.format(self.src_path, self.MSG, self.e.msg, self.e.lineno,
                          self.e.colno, self.e.pos)


ERRORS = {
    AttributeError: LiveAttributeError,
    ExternalNotFoundError: LiveExternalNotFoundError,
    TemplateNotFound: LiveTemplateNotFound,
    TemplateSyntaxError: LiveTemplateSyntaxError,
    TypeError: LiveTypeError,
    UndefinedError: LiveUndefinedError,
    UnicodeDecodeError: LiveUnicodeDecodeError,
    UnicodeEncodeError: LiveUnicodeEncodeError,
    ValueError: LiveValueError,
}
if six.PY3:
    try:
        from json.decoder import JSONDecodeError
        ERRORS[JSONDecodeError] = LiveJSONDecodeError
    except ImportError:
        pass