Skip to content

Commit

Permalink
start setting up the entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
sinaatalay committed Oct 8, 2023
1 parent a90e211 commit ceb4384
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
6 changes: 2 additions & 4 deletions rendercv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
It parses the user input YAML/JSON file and validates the data (checks spelling mistakes, checks if the dates are consistent, etc.). Then, with the data, it creates a $\LaTeX$ file and renders it with [TinyTeX](https://yihui.org/tinytex/).
"""

# initialize logging:
import logging


Expand Down Expand Up @@ -36,7 +34,7 @@ def format(self, record):


logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
stdout_handler = logging.StreamHandler()
stdout_handler.setLevel(logging.INFO)
stdout_handler.setFormatter(LoggingFormatter())
logger.addHandler(stdout_handler)
logger.addHandler(stdout_handler)
36 changes: 36 additions & 0 deletions rendercv/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
This module is a script to run the RenderCV and generate a CV as a PDF. It is an entry
point for the RenderCV package.
"""
import os
import logging
import sys

from rendercv.rendering import read_input_file, render_template, run_latex


def main(args=sys.argv[1:]):
"""
This is the main function to run RenderCV.
"""
logger = logging.getLogger(__name__)

if len(args) != 1:
raise ValueError("Please provide the input file path.")
elif len(args) == 1:
input_file_path = args[0]
else:
raise ValueError(
"More than one input is provided. Please provide only one input, which is"
" the input file path."
)

input_file_path = sys.argv[1]
file_path = os.path.join(os.getcwd(), input_file_path)
data = read_input_file(file_path)
output_latex_file = render_template(data)
output_pdf_file = run_latex(output_latex_file)
logger.info(f"RenderCV: PDF file generated at {output_pdf_file}")

if __name__ == "__main__":
main()
15 changes: 3 additions & 12 deletions run_rendercv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@

import os

from ruamel.yaml import YAML

from rendercv.data_model import RenderCVDataModel
from rendercv.rendering import render_template, run_latex
import rendercv

input_name = "personal"
workspace = os.path.dirname(__file__)
file_path = os.path.join(workspace, "tests", "inputs", f"{input_name}.yaml")

input_file_path = os.path.join(workspace, "tests", "inputs", f"{input_name}.yaml")
with open(input_file_path) as file:
yaml = YAML()
raw_json = yaml.load(file)

data = RenderCVDataModel(**raw_json)
output_latex_file=render_template(data=data)

run_latex(output_latex_file)
rendercv(file_path)
14 changes: 14 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from setuptools import setup, find_packages

setup(
name="rendercv",
version="1.0",
author="Sina Atalay",
description="A Python package to generate a CV as a PDF from a YAML or JSON file.",
packages=find_packages(),
entry_points={
"console_scripts": [
"rendercv = rendercv.cli:main",
]
},
)

0 comments on commit ceb4384

Please sign in to comment.