mirror of https://github.com/eyhc1/rendercv.git
avoid using __file__
This commit is contained in:
parent
ab503f9c79
commit
5562685768
|
@ -14,6 +14,7 @@ import logging
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
import urllib.request
|
import urllib.request
|
||||||
import os
|
import os
|
||||||
|
from importlib.resources import files
|
||||||
|
|
||||||
from pydantic import (
|
from pydantic import (
|
||||||
BaseModel,
|
BaseModel,
|
||||||
|
@ -455,7 +456,7 @@ class Design(BaseModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_font(cls, font: str) -> str:
|
def check_font(cls, font: str) -> str:
|
||||||
# Go to fonts directory and check if the font exists:
|
# Go to fonts directory and check if the font exists:
|
||||||
fonts_directory = os.path.join(os.path.dirname(__file__), "templates", "fonts")
|
fonts_directory = str(files("rendercv").joinpath("templates", "fonts"))
|
||||||
if font not in os.listdir(fonts_directory):
|
if font not in os.listdir(fonts_directory):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f'The font "{font}" is not found in the "fonts" directory! To add a new'
|
f'The font "{font}" is not found in the "fonts" directory! To add a new'
|
||||||
|
@ -479,7 +480,7 @@ class Design(BaseModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def check_if_theme_exists(cls, theme: str) -> str:
|
def check_if_theme_exists(cls, theme: str) -> str:
|
||||||
# Go to templates directory and check if the theme exists:
|
# Go to templates directory and check if the theme exists:
|
||||||
template_directory = os.path.join(os.path.dirname(__file__), "templates", theme)
|
template_directory = str(files("rendercv").joinpath("templates", theme))
|
||||||
if f"{theme}.tex.j2" not in os.listdir(template_directory):
|
if f"{theme}.tex.j2" not in os.listdir(template_directory):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f'The theme "{theme}" is not found in the "templates" directory! To add'
|
f'The theme "{theme}" is not found in the "templates" directory! To add'
|
||||||
|
@ -1235,7 +1236,7 @@ class RenderCVDataModel(BaseModel):
|
||||||
design: Design = model.design
|
design: Design = model.design
|
||||||
cv: CurriculumVitae = model.cv
|
cv: CurriculumVitae = model.cv
|
||||||
section_titles = [section.title for section in cv.sections]
|
section_titles = [section.title for section in cv.sections]
|
||||||
for title in design.options.show_timespan_in:
|
for title in design.options.show_timespan_in: # type: ignore
|
||||||
if title not in section_titles:
|
if title not in section_titles:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f'The section "{title}" that is specified in the'
|
f'The section "{title}" that is specified in the'
|
||||||
|
|
Loading…
Reference in New Issue