
| Current Path : /proc/thread-self/root/usr/local/lib/python3.8/dist-packages/silverware/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //proc/thread-self/root/usr/local/lib/python3.8/dist-packages/silverware/HtmlFile.py |
from disk import Path
from bs4 import BeautifulSoup
from .Spoon import Spoon
class HtmlFile(Path):
def __init__(self, string, show_size=False):
super().__init__(string=string, show_size=show_size)
self._soup = None
self._spoon = None
self._paragraphs = None
def __repr__(self):
return self.name_and_extension
def __str__(self):
return repr(self)
@property
def soup(self):
"""
:rtype: BeautifulSoup
"""
if self._soup is None:
self._soup = BeautifulSoup('\n'.join(self.read_lines()), 'lxml')
return self._soup
@property
def spoon(self):
"""
:rtype: Spoon
"""
if self._spoon is None:
self._spoon = Spoon(soup=self.soup)
return self._spoon
def extract_soup(self):
"""
:rtype: BeautifulSoup
"""
soup = self.soup
self._soup = None
self._spoon = None
return soup