(zip_path: str, image_list: List[str])
| 181 | |
| 182 | |
| 183 | def 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 | |
| 204 | def update_document_char_length(document_id: str): |
no test coverage detected