NexusInstruments commited on
Commit
a7d33e4
·
verified ·
1 Parent(s): b69d16a

Delete pages/FixImports.py

Browse files
Files changed (1) hide show
  1. pages/FixImports.py +0 -71
pages/FixImports.py DELETED
@@ -1,71 +0,0 @@
1
- import sys, os
2
-
3
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4
- UTILS_DIR = os.path.join(BASE_DIR, "utils")
5
-
6
- if UTILS_DIR not in sys.path:
7
- sys.path.insert(0, UTILS_DIR)
8
-
9
- import os
10
- import re
11
- import streamlit as st
12
-
13
- st.title("🧩 Import Path Fixer")
14
- st.write("Automatically patch missing `utils` imports across the Omniscient Framework.")
15
-
16
- # ─── Configuration ─────────────────────────────────────────────
17
- PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
18
- SEARCH_PATHS = [
19
- os.path.join(PROJECT_ROOT, "pages"),
20
- os.path.join(PROJECT_ROOT, "utils"),
21
- PROJECT_ROOT,
22
- ]
23
-
24
- # ─── Helper Function ───────────────────────────────────────────
25
- def fix_imports_in_file(file_path):
26
- """
27
- Scans a .py file and replaces any `from utils.` imports
28
- with `from omniscientframework.utils.` for portability.
29
- """
30
- try:
31
- with open(file_path, "r", encoding="utf-8") as f:
32
- content = f.read()
33
-
34
- new_content = re.sub(
35
- r"from\s+utils(\.[\w_]+)?\s+import",
36
- r"from omniscientframework.utils\1 import",
37
- content,
38
- )
39
-
40
- if new_content != content:
41
- with open(file_path, "w", encoding="utf-8") as f:
42
- f.write(new_content)
43
- return True
44
- return False
45
-
46
- except Exception as e:
47
- st.error(f"⚠️ Error fixing {file_path}: {e}")
48
- return False
49
-
50
-
51
- # ─── UI ────────────────────────────────────────────────────────
52
- if st.button("🔧 Fix All Imports Now"):
53
- modified_files = []
54
- for search_dir in SEARCH_PATHS:
55
- for root, _, files in os.walk(search_dir):
56
- for fname in files:
57
- if fname.endswith(".py"):
58
- fpath = os.path.join(root, fname)
59
- if fix_imports_in_file(fpath):
60
- modified_files.append(fpath)
61
-
62
- if modified_files:
63
- st.success(f"✅ Fixed imports in {len(modified_files)} files.")
64
- st.write("### Modified Files:")
65
- for f in modified_files:
66
- st.code(f.replace(PROJECT_ROOT, ""), language="bash")
67
- else:
68
- st.info("✅ All imports already use the correct `omniscientframework.utils` format.")
69
-
70
- st.markdown("---")
71
- st.caption("⚙️ Import Fixer v1.0 — Omniscient Framework internal utility.")