mirror of https://github.com/eyhc1/rendercv.git
avod using bare excepts
This commit is contained in:
parent
ce4a1a5901
commit
e5efd21b0a
|
@ -1,6 +1,8 @@
|
||||||
r"""RenderCV package.
|
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/).
|
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/).
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,13 @@ def main(args=sys.argv[1:]):
|
||||||
" the input file path."
|
" the input file path."
|
||||||
)
|
)
|
||||||
|
|
||||||
input_file_path = sys.argv[1]
|
# input_file_path = sys.argv[1]
|
||||||
file_path = os.path.join(os.getcwd(), input_file_path)
|
file_path = os.path.join(os.getcwd(), input_file_path)
|
||||||
data = read_input_file(file_path)
|
data = read_input_file(file_path)
|
||||||
output_latex_file = render_template(data)
|
output_latex_file = render_template(data)
|
||||||
output_pdf_file = run_latex(output_latex_file)
|
output_pdf_file = run_latex(output_latex_file)
|
||||||
logger.info(f"RenderCV: PDF file generated at {output_pdf_file}")
|
logger.info(f"RenderCV: PDF file generated at {output_pdf_file}")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main(args=["tests/inputs/personal.yaml"])
|
||||||
|
|
|
@ -191,6 +191,9 @@ def format_date(date: Date) -> str:
|
||||||
Returns:
|
Returns:
|
||||||
str: The formatted date.
|
str: The formatted date.
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(date, Date):
|
||||||
|
raise TypeError("date is not a Date object!")
|
||||||
|
|
||||||
# Month abbreviations,
|
# Month abbreviations,
|
||||||
# taken from: https://web.library.yale.edu/cataloging/months
|
# taken from: https://web.library.yale.edu/cataloging/months
|
||||||
abbreviations_of_months = [
|
abbreviations_of_months = [
|
||||||
|
@ -683,7 +686,7 @@ class Event(BaseModel):
|
||||||
# If this runs, it means the date is an ISO format string, and it can be
|
# If this runs, it means the date is an ISO format string, and it can be
|
||||||
# parsed
|
# parsed
|
||||||
month_and_year = format_date(self.date)
|
month_and_year = format_date(self.date)
|
||||||
except:
|
except TypeError:
|
||||||
month_and_year = self.date
|
month_and_year = self.date
|
||||||
else:
|
else:
|
||||||
# Then it means start_date and end_date are provided and month_and_year
|
# Then it means start_date and end_date are provided and month_and_year
|
||||||
|
@ -829,7 +832,7 @@ class PublicationEntry(Event):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
urllib.request.urlopen(doi_url)
|
urllib.request.urlopen(doi_url)
|
||||||
except:
|
except urllib.request.HTTPError:
|
||||||
raise ValueError(f"{doi} cannot be found in the DOI System.")
|
raise ValueError(f"{doi} cannot be found in the DOI System.")
|
||||||
|
|
||||||
return doi
|
return doi
|
||||||
|
|
|
@ -5,10 +5,10 @@ This module is a script to run the RenderCV and generate a CV as a PDF.
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
import rendercv
|
import rendercv.__main__ as rendercv
|
||||||
|
|
||||||
input_name = "personal"
|
input_name = "personal"
|
||||||
workspace = os.path.dirname(__file__)
|
workspace = os.path.dirname(__file__)
|
||||||
file_path = os.path.join(workspace, "tests", "inputs", f"{input_name}.yaml")
|
file_path = os.path.join(workspace, "tests", "inputs", f"{input_name}.yaml")
|
||||||
|
|
||||||
rendercv(file_path)
|
rendercv.main(args=[file_path])
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
\LenToUnit{\paperwidth-1.35 cm},
|
\LenToUnit{\paperwidth-1.35 cm},
|
||||||
\LenToUnit{\paperheight-0.675 cm}
|
\LenToUnit{\paperheight-0.675 cm}
|
||||||
){\vtop{{\null}\makebox[0pt][c]{
|
){\vtop{{\null}\makebox[0pt][c]{
|
||||||
\small\color{gray}\emph{Last updated on October 08, 2023} \hspace{\widthof{Last updated on October 08, 2023}}
|
\small\color{gray}\emph{Last updated on REPLACE_THIS_WITH_TODAY} \hspace{\widthof{Last updated on REPLACE_THIS_WITH_TODAY}}
|
||||||
}}}%
|
}}}%
|
||||||
}%
|
}%
|
||||||
}%
|
}%
|
||||||
|
|
|
@ -5,8 +5,6 @@ import shutil
|
||||||
|
|
||||||
from rendercv import rendering, data_model
|
from rendercv import rendering, data_model
|
||||||
|
|
||||||
from pydantic import ValidationError
|
|
||||||
|
|
||||||
|
|
||||||
class TestDataModel(unittest.TestCase):
|
class TestDataModel(unittest.TestCase):
|
||||||
def test_markdown_to_latex(self):
|
def test_markdown_to_latex(self):
|
||||||
|
@ -378,6 +376,9 @@ class TestDataModel(unittest.TestCase):
|
||||||
output = file.read()
|
output = file.read()
|
||||||
with open(reference_file_path, "r") as file:
|
with open(reference_file_path, "r") as file:
|
||||||
reference = file.read()
|
reference = file.read()
|
||||||
|
reference = reference.replace(
|
||||||
|
"REPLACE_THIS_WITH_TODAY", rendering.get_today()
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(output, reference)
|
self.assertEqual(output, reference)
|
||||||
|
|
||||||
|
@ -406,5 +407,6 @@ class TestDataModel(unittest.TestCase):
|
||||||
|
|
||||||
# rendering.run_latex(latex_file_path)
|
# rendering.run_latex(latex_file_path)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Reference in New Issue