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

Function write_image

apps/knowledge/serializers/common.py:183–201  ·  view source on GitHub ↗
(zip_path: str, image_list: List[str])

Source from the content-addressed store, hash-verified

181
182
183def write_image(zip_path: str, image_list: List[str]):
184 for image in image_list:
185 search = re.search("\(.*\)", image)
186 if search:
187 text = search.group()
188 if text.startswith('(./oss/file/'):
189 image_id = text.replace('(./oss/file/', '').replace(')', '')
190 image_id = image_id.strip().split(" ")[0]
191 if not is_valid_uuid(image_id):
192 continue
193 file = QuerySet(File).filter(id=image_id).first()
194 if file is None:
195 continue
196 zip_inner_path = os.path.join('oss', 'file', image_id)
197 file_path = os.path.join(zip_path, zip_inner_path)
198 if not os.path.exists(os.path.dirname(file_path)):
199 os.makedirs(os.path.dirname(file_path))
200 with open(os.path.join(zip_path, file_path), 'wb') as f:
201 f.write(file.get_bytes())
202
203
204def update_document_char_length(document_id: str):

Callers 4

export_zipMethod · 0.90
export_knowledgeMethod · 0.90
export_zipMethod · 0.90
batch_export_zipMethod · 0.90

Calls 6

searchMethod · 0.80
replaceMethod · 0.80
get_bytesMethod · 0.80
is_valid_uuidFunction · 0.70
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected