-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_python_code.py
More file actions
39 lines (31 loc) · 1.93 KB
/
Copy pathfix_python_code.py
File metadata and controls
39 lines (31 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import json
import re
# 1. Update company_researcher.py
with open("company_researcher.py", "r", encoding="utf-8") as f:
content = f.read()
header_start = "# ── Large Company Pool ───────────────────────────────────────────────────────"
if header_start in content:
content = content[:content.index(header_start)]
replacement = """ pool_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data", "company_pool.json")
try:
with open(pool_path, "r", encoding="utf-8") as f:
return json.load(f)
except Exception as e:
logger.error(f"Failed to load company pool: {e}")
return []"""
content = content.replace(" return COMPANY_POOL", replacement)
content = content.replace("for c in COMPANY_POOL", "for c in self.get_company_pool()")
content = content.replace("except Exception:\n pass", "except Exception as e:\n logger.debug(f\"Ignored error: {e}\")")
content = content.replace("except Exception:\n pass", "except Exception as e:\n logger.debug(f\"Ignored error: {e}\")")
with open("company_researcher.py", "w", encoding="utf-8") as f:
f.write(content.strip() + "\n")
# 2. Update daily_scheduler.py
with open("daily_scheduler.py", "r", encoding="utf-8") as f:
ds_content = f.read()
ds_content = ds_content.replace("except Exception:\n pass", "except Exception as e:\n logger.debug(f\"Ignored error: {e}\")")
ds_content = ds_content.replace("subject=subject if 'subject' in dir() else \"\",", "subject=locals().get('subject', ''),")
ds_content = ds_content.replace("body=body if 'body' in dir() else \"\",", "body=locals().get('body', ''),")
with open("daily_scheduler.py", "w", encoding="utf-8") as f:
f.write(ds_content)
print("Python files updated successfully")