74 lines
3.5 KiB
Python
74 lines
3.5 KiB
Python
"""One-off: rewrite imports for advisor-agent merge (run from repo root)."""
|
|||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import re
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parents[2]
|
||
|
|
|
||
|
|
REPLACEMENTS = [
|
||
|
|
("from app.model.schemas import", "from app.model.advisor_schemas import"),
|
||
|
|
("from app.model.entities import ScriptTemplate", "from app.model.entities_advisor import ScriptTemplate"),
|
||
|
|
("from app.model.entities import ComplianceRule", "from app.model.entities_advisor import ComplianceRule"),
|
||
|
|
("from app.model.entities import ComplianceCheckLog", "from app.model.entities_advisor import ComplianceCheckLog"),
|
||
|
|
("from app.model.entities import CopyTrackLog", "from app.model.entities_advisor import CopyTrackLog"),
|
||
|
|
("from app.model.entities import KycSession", "from app.model.entities_advisor import KycSession"),
|
||
|
|
("from app.model.entities import MarketAlert", "from app.model.entities_advisor import MarketAlert"),
|
||
|
|
("from app.model.entities import TemplateUseLog", "from app.model.entities_advisor import TemplateUseLog"),
|
||
|
|
("from app.repository.template_repository import", "from app.repository.script_template_repository import"),
|
||
|
|
("from app.service.template_vector_service import", "from app.service.script_template_vector_service import"),
|
||
|
|
("from app.service.template_service import", "from app.service.script_template_service import"),
|
||
|
|
("TemplateRepository", "ScriptTemplateRepository"),
|
||
|
|
("TemplateVectorService", "ScriptTemplateVectorService"),
|
||
|
|
("class TemplateService:", "class ScriptTemplateService:"),
|
||
|
|
("TemplateService(", "ScriptTemplateService("),
|
||
|
|
("from app.api.deps import get_auth_context, require_permission", "from app.api.advisor_auth_adapter import get_advisor_auth, require_advisor_permission"),
|
||
|
|
("from app.api.deps import require_permission", "from app.api.advisor_auth_adapter import require_advisor_permission"),
|
||
|
|
("from app.api.deps import get_auth_context", "from app.api.advisor_auth_adapter import get_advisor_auth"),
|
||
|
|
("require_permission(", "require_advisor_permission("),
|
||
|
|
("get_auth_context", "get_advisor_auth"),
|
||
|
|
("AuthContext", "AdvisorAuthContext"),
|
||
|
|
("from app.model.advisor_schemas import AdvisorAuthContext", "from app.api.advisor_auth_adapter import AdvisorAuthContext"),
|
||
|
|
("success_response", "_advisor_ok"),
|
||
|
|
("from app.utils.response import _advisor_ok", "from app.api.advisor_http import advisor_ok as _advisor_ok"),
|
||
|
|
]
|
||
|
|
|
||
|
|
GLOBS = [
|
||
|
|
"app/service/compliance_*.py",
|
||
|
|
"app/service/copy_*.py",
|
||
|
|
"app/service/kyc_*.py",
|
||
|
|
"app/service/market_*.py",
|
||
|
|
"app/service/script_template*.py",
|
||
|
|
"app/service/input_guard_service.py",
|
||
|
|
"app/service/ownership_service.py",
|
||
|
|
"app/service/llm_client.py",
|
||
|
|
"app/repository/compliance_*.py",
|
||
|
|
"app/repository/copy_*.py",
|
||
|
|
"app/repository/kyc_*.py",
|
||
|
|
"app/repository/market_*.py",
|
||
|
|
"app/repository/script_template*.py",
|
||
|
|
"app/api/allocation.py",
|
||
|
|
"app/api/copy.py",
|
||
|
|
"app/api/dashboard.py",
|
||
|
|
"app/api/guard.py",
|
||
|
|
"app/api/kyc.py",
|
||
|
|
"app/api/market.py",
|
||
|
|
"app/api/templates.py",
|
||
|
|
"scripts/seed/*.py",
|
||
|
|
"scripts/sync/sync_template_vectors.py",
|
||
|
|
]
|
||
|
|
|
||
|
|
def main() -> None:
|
||
|
|
for pattern in GLOBS:
|
||
|
|
for path in ROOT.glob(pattern):
|
||
|
|
text = path.read_text(encoding="utf-8")
|
||
|
|
orig = text
|
||
|
|
for old, new in REPLACEMENTS:
|
||
|
|
text = text.replace(old, new)
|
||
|
|
if text != orig:
|
||
|
|
path.write_text(text, encoding="utf-8")
|
||
|
|
print("fixed", path.relative_to(ROOT))
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|