ai客服
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

1 month ago
  1. import sys
  2. def rewrite():
  3. with open('/Users/getmind/ds/kf/erp_automation.py', 'r') as f:
  4. lines = f.readlines()
  5. start_idx = -1
  6. end_idx = -1
  7. for i, line in enumerate(lines):
  8. if '# 步骤C: 切换筛选条件 - 取消"等待订单合并",勾选"已付款待审核"' in line:
  9. start_idx = i
  10. break
  11. for i in range(start_idx, len(lines)):
  12. if 'close_msg_dialog("审核结果提示")' in lines[i]:
  13. end_idx = i + 1
  14. break
  15. if start_idx == -1 or end_idx == -1:
  16. print("未找到起点或终点")
  17. return
  18. original_block = lines[start_idx:end_idx]
  19. # 因为原来已经是 12 个空格缩进,现在需要 16 个空格
  20. indented_block = []
  21. for line in original_block:
  22. if line.strip() == "":
  23. indented_block.append(line)
  24. elif line.startswith(" "):
  25. indented_block.append(" " + line)
  26. else:
  27. indented_block.append(" " + line)
  28. lines = lines[:start_idx] + indented_block + lines[end_idx:]
  29. with open('/Users/getmind/ds/kf/erp_automation.py', 'w') as f:
  30. f.writelines(lines)
  31. if __name__ == '__main__':
  32. rewrite()