made bs4 and soupsieve standalone in this project

This commit is contained in:
2025-04-24 19:26:20 +02:00
parent aefb27614f
commit 3dd7b5a18d
17 changed files with 68 additions and 62 deletions

View File

@ -4,7 +4,7 @@ __license__ = "MIT"
from collections import defaultdict
import itertools
import sys
from ...bs4.element import (
from ..element import (
CharsetMetaAttributeValue,
ContentMetaAttributeValue,
Stylesheet,

View File

@ -7,13 +7,13 @@ __all__ = [
import warnings
import re
from ...bs4.builder import (
from . import (
PERMISSIVE,
HTML,
HTML_5,
HTMLTreeBuilder,
)
from ...bs4.element import (
from ..element import (
NamespacedAttribute,
nonwhitespace_re,
)
@ -22,7 +22,7 @@ from html5lib.constants import (
namespaces,
prefixes,
)
from ...bs4.element import (
from ..element import (
Comment,
Doctype,
NavigableString,
@ -120,7 +120,7 @@ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder):
if soup:
self.soup = soup
else:
from ...bs4 import BeautifulSoup
from .. import BeautifulSoup
# TODO: Why is the parser 'html.parser' here? To avoid an
# infinite loop?
self.soup = BeautifulSoup(
@ -166,7 +166,7 @@ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder):
return TextNode(Comment(data), self.soup)
def fragmentClass(self):
from ...bs4 import BeautifulSoup
from .. import BeautifulSoup
# TODO: Why is the parser 'html.parser' here? To avoid an
# infinite loop?
self.soup = BeautifulSoup("", "html.parser")
@ -184,7 +184,7 @@ class TreeBuilderForHtml5lib(treebuilder_base.TreeBuilder):
return treebuilder_base.TreeBuilder.getFragment(self).element
def testSerializer(self, element):
from ...bs4 import BeautifulSoup
from .. import BeautifulSoup
rv = []
doctype_re = re.compile(r'^(.*?)(?: PUBLIC "(.*?)"(?: "(.*?)")?| SYSTEM "(.*?)")?$')

View File

@ -34,16 +34,16 @@ CONSTRUCTOR_STRICT_IS_DEPRECATED = major == 3 and minor == 3
CONSTRUCTOR_TAKES_CONVERT_CHARREFS = major == 3 and minor >= 4
from ...bs4.element import (
from ..element import (
CData,
Comment,
Declaration,
Doctype,
ProcessingInstruction,
)
from ...bs4.dammit import EntitySubstitution, UnicodeDammit
from ..dammit import EntitySubstitution, UnicodeDammit
from ...bs4.builder import (
from . import (
HTML,
HTMLTreeBuilder,
STRICT,

View File

@ -14,14 +14,14 @@ except ImportError as e:
from io import BytesIO
from io import StringIO
from lxml import etree
from ...bs4.element import (
from ..element import (
Comment,
Doctype,
NamespacedAttribute,
ProcessingInstruction,
XMLProcessingInstruction,
)
from ...bs4.builder import (
from . import (
FAST,
HTML,
HTMLTreeBuilder,
@ -29,7 +29,7 @@ from ...bs4.builder import (
ParserRejectedMarkup,
TreeBuilder,
XML)
from ...bs4.dammit import EncodingDetector
from ..dammit import EncodingDetector
LXML = 'lxml'