(result_list: list, zip_files: List[str])
| 67 | |
| 68 | |
| 69 | def get_image_list(result_list: list, zip_files: List[str]): |
| 70 | image_file_list = [] |
| 71 | for result in result_list: |
| 72 | for p in result.get('content', []): |
| 73 | content: str = p.get('content', '') |
| 74 | image_list = parse_md_image(content) |
| 75 | for image in image_list: |
| 76 | search = re.search("\(.*\)", image) |
| 77 | if search: |
| 78 | new_image_id = str(uuid.uuid7()) |
| 79 | source_image_path = search.group().replace('(', '').replace(')', '') |
| 80 | source_image_path = source_image_path.strip().split(" ")[0] |
| 81 | image_path = urljoin(result.get('name'), '.' + source_image_path if source_image_path.startswith( |
| 82 | '/') else source_image_path) |
| 83 | if not zip_files.__contains__(image_path): |
| 84 | continue |
| 85 | if image_path.startswith('oss/file/') or image_path.startswith('oss/image/'): |
| 86 | image_id = image_path.replace('oss/file/', '').replace('oss/image/', '') |
| 87 | if is_valid_uuid(image_id): |
| 88 | image_file_list.append({'source_file': image_path, |
| 89 | 'image_id': image_id}) |
| 90 | else: |
| 91 | image_file_list.append({'source_file': image_path, |
| 92 | 'image_id': new_image_id}) |
| 93 | content = content.replace(source_image_path, f'./oss/file/{new_image_id}') |
| 94 | p['content'] = content |
| 95 | else: |
| 96 | image_file_list.append({'source_file': image_path, |
| 97 | 'image_id': new_image_id}) |
| 98 | content = content.replace(source_image_path, f'./oss/file/{new_image_id}') |
| 99 | p['content'] = content |
| 100 | |
| 101 | return image_file_list |
| 102 | |
| 103 | |
| 104 | def get_image_list_by_content(name: str, content: str, zip_files: List[str]): |
no test coverage detected