-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinit.py
More file actions
48 lines (36 loc) · 1.4 KB
/
Copy pathinit.py
File metadata and controls
48 lines (36 loc) · 1.4 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
40
41
42
43
44
45
46
47
48
"""
init.py
Zero-configuration entry point. Just hit Run on this file -- no script
parameters, no working directory setup, nothing to configure.
It will:
1. Generate a synthetic raw_notes/ folder (20 files) if one doesn't
already exist next to this file.
2. Compile it into compiled_wiki/.
3. Print the lint report.
Paths are resolved relative to this file's own location, not PyCharm's
working directory, so it works regardless of Run Configuration settings.
"""
import os
import sys
# Ensure imports work regardless of PyCharm's working directory setting.
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, THIS_DIR)
from generator import generate_corpus
from compiler import compile_wiki
from linter import print_report
RAW_DIR = os.path.join(THIS_DIR, "raw_notes")
OUTPUT_DIR = os.path.join(THIS_DIR, "compiled_wiki")
NUM_FILES = 20
SEED = 42
def main():
if not os.path.isdir(RAW_DIR) or not os.listdir(RAW_DIR):
print(f"No raw notes found -- generating {NUM_FILES} synthetic files...")
generate_corpus(RAW_DIR, num_files=NUM_FILES, seed=SEED)
print(f"Wrote raw notes to {RAW_DIR}")
else:
print(f"Using existing raw notes in {RAW_DIR}")
result = compile_wiki(RAW_DIR, OUTPUT_DIR)
print(f"\nCompiled {len(result['written_paths'])} pages -> {OUTPUT_DIR}\n")
print_report(result["lint_report"])
if __name__ == "__main__":
main()