small clean

This commit is contained in:
Eric Yu 2024-07-05 12:58:09 -07:00
parent ed5b0d48a4
commit 2304d0250f
3 changed files with 41 additions and 25 deletions

View File

@ -66,7 +66,7 @@ description = 'A LaTeX CV/resume framework'
authors = [{ name = 'Sina Atalay', email = 'dev@atalay.biz' }] authors = [{ name = 'Sina Atalay', email = 'dev@atalay.biz' }]
license = "MIT" license = "MIT"
readme = "README.md" readme = "README.md"
requires-python = '>=3.10' # requires-python = '>=3.10'
# RenderCV depends on these packages. They will be installed automatically when RenderCV # RenderCV depends on these packages. They will be installed automatically when RenderCV
# is installed: # is installed:
dependencies = [ dependencies = [

View File

@ -34,9 +34,8 @@ from .themes.classic import ClassicThemeOptions
from .themes.engineeringresumes import EngineeringresumesThemeOptions from .themes.engineeringresumes import EngineeringresumesThemeOptions
from .themes.moderncv import ModerncvThemeOptions from .themes.moderncv import ModerncvThemeOptions
from .themes.sb2nov import Sb2novThemeOptions from .themes.sb2nov import Sb2novThemeOptions
from .themes import ThemeOptions
# Disable Pydantic warnings:
warnings.filterwarnings("ignore")
# The dictionary below will be overwritten by LocaleCatalog class. # The dictionary below will be overwritten by LocaleCatalog class.
@ -115,7 +114,7 @@ class RenderCVBaseModel(pydantic.BaseModel):
unknown key is provided in the input file. unknown key is provided in the input file.
""" """
model_config = pydantic.ConfigDict(extra="forbid") model_config = pydantic.ConfigDict(extra="allow")
# ====================================================================================== # ======================================================================================
@ -792,6 +791,7 @@ def validate_section_input(
"entries": sections_input, "entries": sections_input,
} }
# Parse the section:
try: try:
section_type.model_validate( section_type.model_validate(
test_section, test_section,
@ -1236,6 +1236,15 @@ class RenderCVDataModel(RenderCVBaseModel):
# Convert the arguments to a tuple # Convert the arguments to a tuple
theme_data_model_types_tuple = tuple(theme_data_model_types.__args__) if hasattr(theme_data_model_types, '__args__') else (theme_data_model_types,) theme_data_model_types_tuple = tuple(theme_data_model_types.__args__) if hasattr(theme_data_model_types, '__args__') else (theme_data_model_types,)
# Due to how the original code is written, we need to check the custom theme is not in any other folder than the working directory.
parent_folder = pathlib.Path(design["theme"]).parent
if parent_folder.name:
raise ValueError(
f"The custom theme folder should be in the working directory as the input file. Please move the custom theme folder from {parent_folder.absolute()} to the working directory {pathlib.Path.cwd()}.",
"theme",
design["theme"],
)
if isinstance(design, theme_data_model_types_tuple): if isinstance(design, theme_data_model_types_tuple):
# Then it means RenderCVDataModel is already initialized with a design, so # Then it means RenderCVDataModel is already initialized with a design, so
# return it as is: # return it as is:
@ -1323,7 +1332,11 @@ class RenderCVDataModel(RenderCVBaseModel):
else: else:
# Then it means there is no __init__.py file in the custom theme folder. # Then it means there is no __init__.py file in the custom theme folder.
# Create a dummy data model and use that instead. # Create a dummy data model and use that instead.
class ThemeOptionsAreNotProvided(RenderCVBaseModel): warnings.warn(
f"The custom theme {theme_name} doesn't have an __init__.py file."
" RenderCV will use a dummy data model for the theme options."
)
class ThemeOptionsAreNotProvided(ThemeOptions):
theme: str = theme_name theme: str = theme_name
theme_data_model = ThemeOptionsAreNotProvided(theme=theme_name) theme_data_model = ThemeOptionsAreNotProvided(theme=theme_name)

View File

@ -1029,26 +1029,29 @@ def latex_to_pdf(
) as latex_process: ) as latex_process:
output = latex_process.communicate() # wait for the process to finish output = latex_process.communicate() # wait for the process to finish
if latex_process.returncode != 0: if latex_process.returncode != 0:
raise RuntimeError( # instead of raising the error with the small essay they had, just print out the latex error instead
"Unfortunately, RenderCV's built-in TinyTeX binaries couldn't render" print(output[0].decode("utf-8"))
" this LaTeX file into a PDF. This could be caused by one of two" # # EYHC: This error message is rediculous. Replace it with the actual error message
" reasons:\n\n1- The theme templates might have been updated in a way" # raise RuntimeError(
" RenderCV's TinyTeX cannot render. RenderCV's TinyTeX is minified to" # "Unfortunately, RenderCV's built-in TinyTeX binaries couldn't render"
" keep the package size small. As a result, it doesn't function like a" # " this LaTeX file into a PDF. This could be caused by one of two"
" general-purpose LaTeX distribution.\n2- Special characters, like" # " reasons:\n\n1- The theme templates might have been updated in a way"
" Greek or Chinese letters, that are not compatible with the fonts used" # " RenderCV's TinyTeX cannot render. RenderCV's TinyTeX is minified to"
" or RenderCV's TinyTeX might have been used.\n\nHowever, this issue" # " keep the package size small. As a result, it doesn't function like a"
" can be resolved quickly. RenderCV allows you to run your own LaTeX" # " general-purpose LaTeX distribution.\n2- Special characters, like"
" distribution instead of the built-in TinyTeX. This can be done with" # " Greek or Chinese letters, that are not compatible with the fonts used"
" the '--use-local-latex-command' option, as shown below:\n\nrendercv" # " or RenderCV's TinyTeX might have been used.\n\nHowever, this issue"
" render --use-local-latex-command lualatex John_Doe_CV.yaml\n\nIf you" # " can be resolved quickly. RenderCV allows you to run your own LaTeX"
" ensure that the generated LaTeX file can be compiled by your local" # " distribution instead of the built-in TinyTeX. This can be done with"
" LaTeX distribution, RenderCV will work successfully. You can debug" # " the '--use-local-latex-command' option, as shown below:\n\nrendercv"
" the generated LaTeX file in your LaTeX editor to resolve any bugs." # " render --use-local-latex-command lualatex John_Doe_CV.yaml\n\nIf you"
" Then, you can start using RenderCV with your local LaTeX" # " ensure that the generated LaTeX file can be compiled by your local"
" distribution.\n\nIf you can't solve the problem, please open an issue" # " LaTeX distribution, RenderCV will work successfully. You can debug"
" on GitHub." # " the generated LaTeX file in your LaTeX editor to resolve any bugs."
) # " Then, you can start using RenderCV with your local LaTeX"
# " distribution.\n\nIf you can't solve the problem, please open an issue"
# " on GitHub."
# )
else: else:
try: try:
output = output[0].decode("utf-8") output = output[0].decode("utf-8")