MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / handle

Method handle

apps/common/handle/impl/text/html_split_handle.py:53–77  ·  view source on GitHub ↗
(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image)

Source from the content-addressed store, hash-verified

51 return str(soup)
52
53 def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
54 buffer = get_buffer(file)
55 if type(limit) is str:
56 limit = int(limit)
57 if type(with_filter) is str:
58 with_filter = with_filter.lower() == 'true'
59 if pattern_list is not None and len(pattern_list) > 0:
60 split_model = SplitModel(pattern_list, with_filter, limit)
61 else:
62 split_model = SplitModel(default_pattern_list, with_filter=with_filter, limit=limit)
63 try:
64 encoding = get_encoding(buffer)
65 content = buffer.decode(encoding)
66 content = self._remove_anchor_links(content)
67 content = markdownify(content, heading_style='ATX')
68 except BaseException as e:
69 maxkb_logger.error(f"Error processing HTML file {file.name}: {e}, {traceback.format_exc()}")
70
71 return {
72 'name': file.name, 'content': []
73 }
74 return {
75 'name': file.name,
76 'content': split_model.parse(content)
77 }
78
79 def get_content(self, file, save_image):
80 buffer = file.read()

Callers

nothing calls this directly

Calls 6

_remove_anchor_linksMethod · 0.95
parseMethod · 0.95
SplitModelClass · 0.90
get_encodingFunction · 0.85
decodeMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected