How to use the html2text.images_to_alt function in html2text

To help you get started, we’ve selected a few html2text 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 ovh / cerberus-core / abuse / services / email / default.py View on Github external
from django.template.base import TemplateEncodingError
from django.template import engines, TemplateSyntaxError

from .base import (
    EMAIL_VALID_CATEGORIES,
    Email,
    EmailServiceBase,
    EmailServiceException,
    PrefetchedEmail,
)
from ...models import MailTemplate, Ticket

django_template_engine = engines["django"]

html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True


class TemplateNeedProofError(Exception):
    """
        TemplateNeedProofError
    """

    def __init__(self, message):
        super(TemplateNeedProofError, self).__init__(message)


class DefaultMailerService(EmailServiceBase):
    """
        Handling basic mailer interactions. Store emails in a naive sqlite DB.
github ovh / cerberus-core / abuse / api / controllers / reports.py View on Github external
from ...models import (
    AbusePermission,
    Defendant,
    Report,
    ReportItem,
    Service,
    Tag,
    Ticket,
)
from ...services.search import SearchService, SearchServiceException
from ...services.storage import StorageService, StorageServiceException
from ...parsers import Parser
from ...tasks import enqueue

html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True


def get_reports(**kwargs):
    """ Main endpoint, get all reports from db and eventually contains
        filters (json format) in query like sortBy, where ...
    """
    # Parse filters from request
    filters = {}
    if kwargs.get("filters"):
        try:
            filters = json.loads(unquote(unquote(kwargs["filters"])))
        except (ValueError, SyntaxError, TypeError) as ex:
            raise BadRequest(str(ex.message))
    try:
        limit = int(filters["paginate"]["resultsPerPage"])
github ovh / cerberus-core / utils / utils.py View on Github external
email_queue = Queue(
    connection=Redis(**settings.REDIS),
    **settings.QUEUE['email']
)

kpi_queue = Queue(
    connection=Redis(**settings.REDIS),
    **settings.QUEUE['kpi']
)

scheduler = Scheduler(connection=Redis(**settings.REDIS))
redis = Redis(**settings.REDIS)

html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True

DNS_ERROR = {
    '-2': 'NXDOMAIN'
}


class CryptoException(Exception):
    """
        CryptoException
    """
    def __init__(self, message):
        super(CryptoException, self).__init__(message)


class Crypto(object):
github ovh / cerberus-core / abuse / utils / text.py View on Github external
from datetime import datetime
from HTMLParser import HTMLParseError

import html2text
from django.db.models import ObjectDoesNotExist
from django.template import TemplateSyntaxError, engines
from django.template.base import TemplateEncodingError


from ..models import MailTemplate
from ..services.email.base import Email


html2text.ignore_images = True
html2text.images_to_alt = True
html2text.ignore_links = True


class EmailThreadTemplateNotFound(Exception):
    """
        EmailThreadTemplateNotFound
    """

    def __init__(self, message):
        super(EmailThreadTemplateNotFound, self).__init__(message)


class EmailThreadTemplateSyntaxError(Exception):
    """
        EmailThreadTemplateSyntaxError
    """