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

Method handle

apps/common/handle/impl/text/text_split_handle.py:49–64  ·  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

47 return False
48
49 def handle(self, file, pattern_list: List, with_filter: bool, limit: int, get_buffer, save_image):
50 buffer = get_buffer(file)
51 if type(limit) is str:
52 limit = int(limit)
53 if type(with_filter) is str:
54 with_filter = with_filter.lower() == 'true'
55 if pattern_list is not None and len(pattern_list) > 0:
56 split_model = SplitModel(pattern_list, with_filter, limit)
57 else:
58 split_model = SplitModel(default_pattern_list, with_filter=with_filter, limit=limit)
59 try:
60 content = buffer.decode(detect(buffer)['encoding'])
61 except BaseException as e:
62 maxkb_logger.error(f"Error processing TEXT file {file.name}: {e}, {traceback.format_exc()}")
63 return {'name': file.name, 'content': []}
64 return {'name': file.name, 'content': split_model.parse(content)}
65
66 def get_content(self, file, save_image):
67 buffer = file.read()

Callers

nothing calls this directly

Calls 4

parseMethod · 0.95
SplitModelClass · 0.90
decodeMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected