generate cv with summary
This commit is contained in:
parent
1b082a3eb6
commit
f9352ad5b0
@ -19,7 +19,7 @@ const crawler = new PlaywrightCrawler({
|
|||||||
maxRequestsPerCrawl: 20,
|
maxRequestsPerCrawl: 20,
|
||||||
// Add delay between requests to slow down the process
|
// Add delay between requests to slow down the process
|
||||||
minConcurrency: 1,
|
minConcurrency: 1,
|
||||||
maxConcurrency: 5,
|
maxConcurrency: 10,
|
||||||
navigationTimeoutSecs: 60,
|
navigationTimeoutSecs: 60,
|
||||||
// Add delay between requests (in milliseconds)
|
// Add delay between requests (in milliseconds)
|
||||||
// requestHandlerTimeoutSecs: 50,
|
// requestHandlerTimeoutSecs: 50,
|
||||||
|
|||||||
@ -11,7 +11,16 @@ RXRESUME_EMAIL = os.getenv("RXRESUME_EMAIL", "")
|
|||||||
RXRESUME_PASSWORD = os.getenv("RXRESUME_PASSWORD", "")
|
RXRESUME_PASSWORD = os.getenv("RXRESUME_PASSWORD", "")
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).parent
|
BASE_DIR = Path(__file__).parent
|
||||||
RESUME_JSON_PATH = BASE_DIR / "base.json"
|
|
||||||
|
# Allow override via environment variables (used by orchestrator)
|
||||||
|
_custom_json_path = os.getenv("RESUME_JSON_PATH")
|
||||||
|
RESUME_JSON_PATH = (
|
||||||
|
Path(_custom_json_path) if _custom_json_path else BASE_DIR / "base.json"
|
||||||
|
)
|
||||||
|
|
||||||
|
_custom_output_filename = os.getenv("OUTPUT_FILENAME")
|
||||||
|
OUTPUT_FILENAME = _custom_output_filename if _custom_output_filename else "resume.pdf"
|
||||||
|
|
||||||
OUTPUT_DIR = BASE_DIR / "resumes"
|
OUTPUT_DIR = BASE_DIR / "resumes"
|
||||||
|
|
||||||
|
|
||||||
@ -61,22 +70,28 @@ def export_pdf(page, output_path: Path) -> Path:
|
|||||||
|
|
||||||
|
|
||||||
def generate_resume_pdf(
|
def generate_resume_pdf(
|
||||||
output_filename: str = "resume.pdf",
|
output_filename: str = None,
|
||||||
import_json: bool = False,
|
import_json: bool = True,
|
||||||
json_path: Path = None,
|
json_path: Path = None,
|
||||||
) -> Path:
|
) -> Path:
|
||||||
"""
|
"""
|
||||||
Import resume and export PDF.
|
Import resume and export PDF.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
output_filename: Name of the output PDF file
|
output_filename: Name of the output PDF file (defaults to OUTPUT_FILENAME env var)
|
||||||
import_json: Whether to import a JSON file first
|
import_json: Whether to import a JSON file first (default True)
|
||||||
json_path: Path to JSON file (if import_json is True)
|
json_path: Path to JSON file (defaults to RESUME_JSON_PATH env var)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Path to the generated PDF
|
Path to the generated PDF
|
||||||
"""
|
"""
|
||||||
output_path = OUTPUT_DIR / output_filename
|
# Use environment-provided defaults
|
||||||
|
actual_filename = output_filename or OUTPUT_FILENAME
|
||||||
|
actual_json_path = json_path or RESUME_JSON_PATH
|
||||||
|
output_path = OUTPUT_DIR / actual_filename
|
||||||
|
|
||||||
|
print(f"📄 Generating PDF: {actual_filename}")
|
||||||
|
print(f" JSON source: {actual_json_path}")
|
||||||
|
|
||||||
with sync_playwright() as playwright:
|
with sync_playwright() as playwright:
|
||||||
browser = playwright.chromium.launch(headless=True)
|
browser = playwright.chromium.launch(headless=True)
|
||||||
@ -87,19 +102,18 @@ def generate_resume_pdf(
|
|||||||
login(page)
|
login(page)
|
||||||
|
|
||||||
if import_json:
|
if import_json:
|
||||||
import_resume(page, json_path or RESUME_JSON_PATH)
|
import_resume(page, actual_json_path)
|
||||||
|
|
||||||
navigate_to_top_resume(page)
|
navigate_to_top_resume(page)
|
||||||
export_pdf(page, output_path)
|
export_pdf(page, output_path)
|
||||||
finally:
|
finally:
|
||||||
browser.close()
|
browser.close()
|
||||||
|
|
||||||
|
print(f"✅ PDF saved: {output_path}")
|
||||||
return output_path
|
return output_path
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
pdf_path = generate_resume_pdf(
|
# When run directly, use environment variables or defaults
|
||||||
output_filename="test_resume.pdf",
|
pdf_path = generate_resume_pdf()
|
||||||
import_json=True,
|
print(f"Done! PDF saved: {pdf_path}")
|
||||||
)
|
|
||||||
print(f"PDF saved: {pdf_path}")
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user