refactor: modular structure, core and services directories
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import os
|
||||
|
||||
def update_file_imports(filepath):
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# Заменяем старые пути на новые
|
||||
new_content = content
|
||||
new_content = new_content.replace("from modules.database", "from core.database")
|
||||
new_content = new_content.replace("import modules.database", "import core.database")
|
||||
|
||||
# Все остальные модули уехали в services/
|
||||
service_modules = [
|
||||
"ai_verifier", "data_loader", "data_validator", "excel_exporter",
|
||||
"feedback_loop", "knowledge_base", "scud_export", "share_copier",
|
||||
"text_reporter", "zup_extractor"
|
||||
]
|
||||
|
||||
for mod in service_modules:
|
||||
new_content = new_content.replace(f"from modules.{mod}", f"from services.{mod}")
|
||||
new_content = new_content.replace(f"import modules.{mod}", f"import services.{mod}")
|
||||
# Также на случай относительных или прямых импортов внутри сервисов друг на друга
|
||||
new_content = new_content.replace(f"from {mod}", f"from services.{mod}")
|
||||
|
||||
if content != new_content:
|
||||
with open(filepath, 'w', encoding='utf-8') as f:
|
||||
f.write(new_content)
|
||||
print(f"[Обновлено] Импорты в файле: {filepath}")
|
||||
|
||||
def run_update():
|
||||
print("=== Автоматическое обновление импортов ===")
|
||||
for root, dirs, files in os.walk("."):
|
||||
if "venv" in root or ".git" in root:
|
||||
continue
|
||||
for file in files:
|
||||
if file.endswith(".py") and file != "migrate_structure.py" and file != "update_imports.py":
|
||||
update_file_imports(os.path.join(root, file))
|
||||
print("=== Обновление завершено ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_update()
|
||||
Reference in New Issue
Block a user