Files
zulip/zerver/lib/url_preview/parsers/base.py
Tim Abbott 4d03c15848 url_preview: Don't import beautifulsoup at import time.
This is a small performance optimization to Django startup, in line
with other recent commits.
2018-08-08 14:19:42 -07:00

13 lines
460 B
Python

from typing import Any
class BaseParser:
def __init__(self, html_source: str) -> None:
# We import BeautifulSoup here, because it's not used by most
# processes in production, and bs4 is big enough that
# importing it adds 10s of milliseconds to manage.py startup.
from bs4 import BeautifulSoup
self._soup = BeautifulSoup(html_source, "lxml")
def extract_data(self) -> Any:
raise NotImplementedError()