diff --git a/rendercv/__init__.py b/rendercv/__init__.py index 564c9c5..9425105 100644 --- a/rendercv/__init__.py +++ b/rendercv/__init__.py @@ -2,8 +2,6 @@ r"""RenderCV package. 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 @@ -36,7 +34,7 @@ class LoggingFormatter(logging.Formatter): logger = logging.getLogger() +logger.setLevel(logging.DEBUG) stdout_handler = logging.StreamHandler() -stdout_handler.setLevel(logging.INFO) stdout_handler.setFormatter(LoggingFormatter()) -logger.addHandler(stdout_handler) \ No newline at end of file +logger.addHandler(stdout_handler) diff --git a/rendercv/__main__.py b/rendercv/__main__.py new file mode 100644 index 0000000..2915bad --- /dev/null +++ b/rendercv/__main__.py @@ -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() \ No newline at end of file diff --git a/run_rendercv.py b/run_rendercv.py index cfa9506..acab402 100644 --- a/run_rendercv.py +++ b/run_rendercv.py @@ -4,20 +4,11 @@ This module is a script to run the RenderCV and generate a CV as a PDF. 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) \ No newline at end of file diff --git a/setup.py b/setup.py index e69de29..b9dd729 100644 --- a/setup.py +++ b/setup.py @@ -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", + ] + }, +)