fix bug
Showing
1 changed file
with
8 additions
and
0 deletions
| ... | @@ -188,6 +188,12 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -188,6 +188,12 @@ class Command(BaseCommand, LoggerMixin): |
| 188 | self.folder_log.error('{0} [wb build error] [path={1}] [error={2}]'.format( | 188 | self.folder_log.error('{0} [wb build error] [path={1}] [error={2}]'.format( |
| 189 | self.log_base, excel_path, traceback.format_exc())) | 189 | self.log_base, excel_path, traceback.format_exc())) |
| 190 | 190 | ||
| 191 | def basename(self, path): | ||
| 192 | # A basename() variant which first strips the trailing slash, if present. | ||
| 193 | # Thus we always get the last component of the path, even for directories. | ||
| 194 | sep = os.path.sep + (os.path.altsep or '') | ||
| 195 | return os.path.basename(path.rstrip(sep)) | ||
| 196 | |||
| 191 | def ocr_process(self, img_path, classify, all_res, seperate_dir): | 197 | def ocr_process(self, img_path, classify, all_res, seperate_dir): |
| 192 | if os.path.exists(img_path): | 198 | if os.path.exists(img_path): |
| 193 | # TODO 图片验证 | 199 | # TODO 图片验证 |
| ... | @@ -225,6 +231,8 @@ class Command(BaseCommand, LoggerMixin): | ... | @@ -225,6 +231,8 @@ class Command(BaseCommand, LoggerMixin): |
| 225 | if ocr_data.get('classify') == classify: | 231 | if ocr_data.get('classify') == classify: |
| 226 | if seperate_dir is not None: | 232 | if seperate_dir is not None: |
| 227 | os.makedirs(seperate_dir, exist_ok=True) | 233 | os.makedirs(seperate_dir, exist_ok=True) |
| 234 | real_dst = os.path.join(seperate_dir, self.basename(img_path)) | ||
| 235 | if not os.path.exists(real_dst): | ||
| 228 | shutil.move(img_path, seperate_dir) | 236 | shutil.move(img_path, seperate_dir) |
| 229 | if classify in consts.LICENSE_CLASSIFY_SET_1: | 237 | if classify in consts.LICENSE_CLASSIFY_SET_1: |
| 230 | self.license1_process(ocr_data, all_res, classify) | 238 | self.license1_process(ocr_data, all_res, classify) | ... | ... |
-
Please register or sign in to post a comment