replace 2
							parent
							
								
									7ff7a4d553
								
							
						
					
					
						commit
						496e35656a
					
				|  | @ -69,6 +69,12 @@ def check_psd(psd_path): | |||
|     all_group_num = [] | ||||
|     # all_color_it_full = [] | ||||
|     # all_color_it_item = [] | ||||
| 
 | ||||
|     all_combination_full = {} | ||||
|     all_combination_items = [] | ||||
|     all_combination_mask = [] | ||||
| 
 | ||||
| 
 | ||||
|     is_exist_base = False | ||||
|     is_exist_titem_group = False | ||||
|     all_occlusion_degree = [] | ||||
|  | @ -83,10 +89,13 @@ def check_psd(psd_path): | |||
|             for item_layer in layer: | ||||
|                 if ' ' in item_layer.name: | ||||
|                     error_log.append(f'{psd_name}:{item_layer.name}:{config.error_log.name_contains_spaces.value}') | ||||
|                 # item_names = item_layer.name.split('_') | ||||
|                 item_names = item_layer.name.split('_') | ||||
|                 last_name = item_names[-1] | ||||
|                 if titem_name in item_layer.name: | ||||
|                     if item_layer.name in all_items: ##or item_layer.name in all_color_it_item: | ||||
|                         error_log.append(f'{psd_name}:{item_layer.name}:{config.error_log.exit_repeat_layer.value}') | ||||
|                     elif int(last_name) >= 1000: | ||||
|                         all_combination_items.append(item_layer.name) | ||||
|                     else: | ||||
|                         # if 'titemcolor' in item_layer.name: | ||||
|                         #     all_color_it_item.append(item_layer.name) | ||||
|  | @ -103,10 +112,10 @@ def check_psd(psd_path): | |||
|                 error_log.append(f'{psd_name}:{layer.name}:{config.error_log.group_name_error.value}') | ||||
|                 print(e) | ||||
|                 continue | ||||
|             if group_num <= 0 or group_num > psd_point_num: | ||||
|                 error_log.append(f'{psd_name}:{layer.name}:{config.error_log.group_name_error.value}') | ||||
|                 continue | ||||
|             else: | ||||
|             # if group_num <= 0 or group_num > psd_point_num: | ||||
|             #     error_log.append(f'{psd_name}:{layer.name}:{config.error_log.group_name_error.value}') | ||||
|             #     continue | ||||
|             # else: | ||||
|             all_group_num.append(group_num) | ||||
| 
 | ||||
|             if not layer.is_group(): | ||||
|  | @ -116,22 +125,32 @@ def check_psd(psd_path): | |||
|             else: | ||||
|                 all_group.append(layer.name) | ||||
|                 is_exit_full = False | ||||
| 
 | ||||
|                 layer_names = layer.name.split('_') | ||||
|                 layer_last_name = layer_names[-1] | ||||
|                 for child_layer in layer: | ||||
|                     if group_num_str not in child_layer.name: | ||||
|                     if group_num_str not in child_layer.name and int(layer_last_name) < 1000: | ||||
|                         error_log.append(f'{psd_name}:{child_layer.name}:{config.error_log.child_layer_not_in_group.value}') | ||||
| 
 | ||||
|                     if child_layer.is_group(): | ||||
|                         error_log.append(f'{psd_name}:{child_layer.name}:{config.error_log.child_layer_is_group.value}') | ||||
|                     else: | ||||
|                         full_names = child_layer.name.split('_') | ||||
|                         last_name = full_names[-1] | ||||
|                         if tfull_name in child_layer.name: | ||||
|                             if child_layer.name in all_full.keys(): | ||||
|                                 error_log.append(f'{psd_name}:{child_layer.name}:{config.error_log.exit_repeat_layer.value}') | ||||
|                             elif int(last_name) >= 1000: | ||||
|                                 all_combination_full[child_layer.name] = (child_layer.left, child_layer.top, child_layer.width, child_layer.height) | ||||
|                                 is_exit_full = True | ||||
|                             else: | ||||
|                                 all_full[child_layer.name] = (child_layer.left, child_layer.top, child_layer.width, child_layer.height) | ||||
|                                 is_exit_full = True | ||||
|                         elif tmask_name in child_layer.name: | ||||
|                             if child_layer.name in all_mask: | ||||
|                                 error_log.append(f'{psd_name}:{child_layer.name}:{config.error_log.exit_repeat_layer.value}') | ||||
|                             elif int(last_name) >= 1000: | ||||
|                                 all_combination_mask.append(child_layer.name) | ||||
|                             else: | ||||
|                                 all_mask.append(child_layer.name) | ||||
|                         elif tshadow_name in child_layer.name: | ||||
|  | @ -157,6 +176,12 @@ def check_psd(psd_path): | |||
|         else: | ||||
|             error_log.append(f'{psd_name}:{layer.name}:{config.error_log.layer_not_need.value}') | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     if not is_exist_base: | ||||
|         error_log.append(f'{psd_name}:{config.error_log.psd_not_exit_base.value}') | ||||
|     if not is_exist_titem_group: | ||||
|  | @ -223,6 +248,29 @@ def check_psd(psd_path): | |||
|         else: | ||||
|             error_log.append(f'{psd_name}:{cur_mask}:{config.error_log.psd_mask_not_full.value}') | ||||
| 
 | ||||
|         for cur_mask in all_combination_mask: | ||||
|             # img_mask = psd.composite(layer_filter=lambda mask_layer: mask_layer.name == cur_mask) | ||||
|             layer_mask = find_layer_by_name(psd, cur_mask) | ||||
|             full_name = cur_mask.replace('mask', 'full') | ||||
|             cur_full_rect = None | ||||
|             if full_name in all_combination_full.keys(): | ||||
|                 cur_full_rect = all_combination_full[full_name] | ||||
|                 # img_full = psd.composite(layer_filter=lambda full_layer: full_layer.name == full_name) | ||||
|                 layer_full = find_layer_by_name(psd, full_name) | ||||
|                 if layer_mask is None or layer_full is None: | ||||
|                     error_log.append(f'{psd_name}:{cur_mask}:{config.error_log.not_find_mask_full.value}') | ||||
|                     break | ||||
|                 img_mask = psd.composite(layer_mask) | ||||
|                 img_full = psd.composite(layer_full) | ||||
| 
 | ||||
|                 # img_mask.save(f'./test/{cur_mask}.png') | ||||
|                 # img_full.save(f'./test/{full_name}.png') | ||||
|                 per = get_item_mask_contact_ratio(img_full, img_mask, cur_full_rect) | ||||
|                 all_occlusion_degree.append(f'{cur_mask}遮挡{full_name}百分比:{per}\n') | ||||
|                 # print(f'{cur_mask}遮挡{full_name}百分比:{per}') | ||||
|             else: | ||||
|                 error_log.append(f'{psd_name}:{cur_mask}:{config.error_log.psd_mask_not_full.value}') | ||||
| 
 | ||||
|     is_error = len(error_log) > 0 | ||||
|     is_error_text = '否' if is_error else '是' | ||||
|     if is_error: | ||||
|  |  | |||
|  | @ -17,7 +17,8 @@ class error_log(enum.Enum): | |||
|     psd_not_full = '没有item对应的full' | ||||
|     psd_not_fullcolor = '没有item对应的fullcolor' | ||||
|     psd_not_itemcolor = '没有item对应的itemcolor' | ||||
|     item_or_full_num_error = 'item,full或itemcolor,fullcolor的个数不全部相同' | ||||
|     item_or_full_num_error = 'full的数量少于item的数量 ' | ||||
|     color_num_error = 'itemcolor,fullcolor的个数不全部相同' | ||||
|     name_contains_spaces = '该图层名字中包含空格' | ||||
|     psd_mask_not_full = '没有mask对应的full' | ||||
|     not_find_mask_full = '没有找到mask或者full' | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue