Spaces:
Runtime error
Runtime error
mehdirabiee commited on
Commit ·
80c10e0
1
Parent(s): c1ae082
together
Browse files- resume_builder.py +0 -85
- resume_parser.py +0 -1
resume_builder.py
DELETED
|
@@ -1,85 +0,0 @@
|
|
| 1 |
-
import io
|
| 2 |
-
from typing import List
|
| 3 |
-
from reportlab.lib.pagesizes import letter
|
| 4 |
-
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, ListFlowable, ListItem
|
| 5 |
-
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
| 6 |
-
from reportlab.lib.enums import TA_LEFT, TA_CENTER
|
| 7 |
-
|
| 8 |
-
from reportlab.lib.units import inch
|
| 9 |
-
|
| 10 |
-
from resume_template import Resume
|
| 11 |
-
# The Class definitions (PersonalDetails, Education, etc.) should be imported or defined above this line.
|
| 12 |
-
# Now assuming those classes are defined and imported if they're in another module.
|
| 13 |
-
|
| 14 |
-
class ResumeGenerator:
|
| 15 |
-
def __init__(self, resume: Resume):
|
| 16 |
-
self.resume: Resume = resume
|
| 17 |
-
self.buffer = io.BytesIO()
|
| 18 |
-
self.styles = getSampleStyleSheet()
|
| 19 |
-
self.custom_styles()
|
| 20 |
-
|
| 21 |
-
def custom_styles(self):
|
| 22 |
-
self.styles.add(ParagraphStyle(name='CustomTitle', parent=self.styles['Title'], fontSize=18, leading=22,
|
| 23 |
-
alignment=TA_CENTER))
|
| 24 |
-
#self.styles.add(ParagraphStyle(name='Heading1', parent=self.styles['Heading1'], spaceAfter=10, fontSize=14))
|
| 25 |
-
self.styles.add(ParagraphStyle(name='NormalIndent', parent=self.styles['Normal'], leftIndent=15))
|
| 26 |
-
|
| 27 |
-
def generate_pdf(self, filename):
|
| 28 |
-
doc = SimpleDocTemplate(self.buffer, pagesize=letter)
|
| 29 |
-
flowables = []
|
| 30 |
-
|
| 31 |
-
self.add_personal_details(flowables)
|
| 32 |
-
self.add_section_title(flowables, "Education")
|
| 33 |
-
self.add_education(flowables)
|
| 34 |
-
self.add_section_title(flowables, "Work Experience")
|
| 35 |
-
self.add_work_experience(flowables)
|
| 36 |
-
self.add_section_title(flowables, "Projects")
|
| 37 |
-
self.add_projects(flowables)
|
| 38 |
-
# Additional sections following the same pattern...
|
| 39 |
-
|
| 40 |
-
doc.build(flowables)
|
| 41 |
-
pdf = self.buffer.getvalue()
|
| 42 |
-
self.buffer.close()
|
| 43 |
-
|
| 44 |
-
with open(filename, 'wb') as f:
|
| 45 |
-
f.write(pdf)
|
| 46 |
-
|
| 47 |
-
def add_personal_details(self, flowables):
|
| 48 |
-
pd = self.resume.personal_details
|
| 49 |
-
flowables.append(Paragraph(f"{pd.first_name} {pd.last_name}", self.styles['CustomTitle']))
|
| 50 |
-
# Include additional personal details as needed...
|
| 51 |
-
flowables.append(Spacer(1, 0.2 * inch))
|
| 52 |
-
|
| 53 |
-
def add_education(self, flowables):
|
| 54 |
-
for edu in self.resume.education:
|
| 55 |
-
flowables.append(Paragraph(
|
| 56 |
-
f"{edu.degree} in {edu.field_of_study}, {edu.institution} ({edu.start_date} - {edu.end_date})",
|
| 57 |
-
self.styles['NormalIndent']))
|
| 58 |
-
flowables.append(Spacer(1, 0.1 * inch))
|
| 59 |
-
|
| 60 |
-
def add_work_experience(self, flowables):
|
| 61 |
-
for work in self.resume.work_experience:
|
| 62 |
-
flowables.append(Paragraph(f"{work.job_title}, {work.company} ({work.start_date} - {work.end_date})",
|
| 63 |
-
self.styles['NormalIndent']))
|
| 64 |
-
flowables.append(Spacer(1, 0.05 * inch))
|
| 65 |
-
contributions = ListFlowable([ListItem(Paragraph(contribution, self.styles['Bullet'])) for contribution in
|
| 66 |
-
(work.notable_contributions or [])], bulletType='bullet', leftIndent=35)
|
| 67 |
-
if work.notable_contributions:
|
| 68 |
-
flowables.append(contributions)
|
| 69 |
-
flowables.append(Spacer(1, 0.1 * inch))
|
| 70 |
-
|
| 71 |
-
# Methods for Projects, Skills, Certifications, etc...
|
| 72 |
-
|
| 73 |
-
def add_projects(self, flowables):
|
| 74 |
-
for project in self.resume.projects:
|
| 75 |
-
flowables.append(Paragraph(f"{project.name}: {project.description}", self.styles['NormalIndent']))
|
| 76 |
-
flowables.append(Spacer(1, 0.1 * inch))
|
| 77 |
-
|
| 78 |
-
def add_section_title(self, flowables, title):
|
| 79 |
-
flowables.append(Spacer(1, 0.2 * inch))
|
| 80 |
-
flowables.append(Paragraph(title, self.styles['Heading1']))
|
| 81 |
-
flowables.append(Spacer(1, 0.1 * inch))
|
| 82 |
-
|
| 83 |
-
# Assuming you have a populated resume_obj of type Resume...
|
| 84 |
-
# resume_generator = ResumeGenerator(resume_obj)
|
| 85 |
-
# resume_generator.generate_pdf('My_Resume.pdf')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resume_parser.py
CHANGED
|
@@ -14,7 +14,6 @@ from langchain_community.llms import HuggingFaceEndpoint
|
|
| 14 |
from langchain_core.messages import BaseMessage
|
| 15 |
from pydantic import ValidationError
|
| 16 |
|
| 17 |
-
from resume_builder import ResumeGenerator
|
| 18 |
from resume_template import Resume
|
| 19 |
|
| 20 |
load_dotenv()
|
|
|
|
| 14 |
from langchain_core.messages import BaseMessage
|
| 15 |
from pydantic import ValidationError
|
| 16 |
|
|
|
|
| 17 |
from resume_template import Resume
|
| 18 |
|
| 19 |
load_dotenv()
|