68 lines
1.9 KiB
Python
68 lines
1.9 KiB
Python
from pathlib import Path
|
|
|
|
import typer
|
|
|
|
from job_research.profile.cv_extractor import extract_cv_signals, extract_pdf_text
|
|
from job_research.profile.merge import build_candidate_profile_output
|
|
from job_research.profile.profile_parser import parse_profile_markdown
|
|
from job_research.storage import save_candidate_profile_yaml
|
|
|
|
app = typer.Typer(help="Build one canonical candidate profile YAML")
|
|
|
|
|
|
@app.callback()
|
|
def main_command() -> None:
|
|
pass
|
|
|
|
@app.command("build-profile")
|
|
def build_profile(
|
|
cv: Path = typer.Option(
|
|
...,
|
|
"--cv",
|
|
exists=True,
|
|
dir_okay=False,
|
|
readable=True,
|
|
help="Path to the CV PDF or UTF-8 text file.",
|
|
),
|
|
profile: Path = typer.Option(
|
|
...,
|
|
"--profile",
|
|
exists=True,
|
|
dir_okay=False,
|
|
readable=True,
|
|
help="Path to the light-template markdown profile.",
|
|
),
|
|
out: Path = typer.Option(
|
|
Path("data/candidate-profile.yaml"),
|
|
"--out",
|
|
dir_okay=False,
|
|
help="Path to write the canonical YAML profile.",
|
|
),
|
|
) -> None:
|
|
"""Build candidate-profile.yaml from CV and markdown profile."""
|
|
|
|
cv_text = extract_pdf_text(cv) if cv.suffix.lower() == ".pdf" else cv.read_text(encoding="utf-8")
|
|
if not cv_text.strip():
|
|
raise ValueError("No readable text found in CV input")
|
|
|
|
authored_profile = parse_profile_markdown(profile.read_text(encoding="utf-8"))
|
|
cv_signals = extract_cv_signals(cv_text)
|
|
candidate_profile = build_candidate_profile_output(cv_signals, authored_profile)
|
|
|
|
save_candidate_profile_yaml(out, candidate_profile)
|
|
|
|
typer.echo(f"candidate profile written to {out}")
|
|
warning_count = len(candidate_profile.warnings)
|
|
if warning_count:
|
|
typer.echo(f"Warnings included: {warning_count}")
|
|
else:
|
|
typer.echo("No warnings included.")
|
|
|
|
|
|
def main() -> None:
|
|
app()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|