generate output dir if not exists
This commit is contained in:
parent
d106c41124
commit
0f461fa98f
@ -23,6 +23,8 @@ class BadgeGeneratorService:
|
||||
|
||||
self.bg_config = config["badge_generator"]
|
||||
self.env = Environment(loader=FileSystemLoader("template"))
|
||||
self.output_path = Path("output_badges")
|
||||
self.output_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
self.svg_template = self.env.get_template(Path(self.bg_config["svg_template"]).name)
|
||||
self.html_template = self.env.get_template(Path(self.bg_config["html_template"]).name)
|
||||
@ -73,7 +75,7 @@ class BadgeGeneratorService:
|
||||
def generate_badge(self, user_name, seat_id, picture) -> None:
|
||||
svg = self._get_user_svg(user_name, seat_id, picture)
|
||||
html = self._get_html_from_svg(svg)
|
||||
output_path = Path(f"output_badges/{user_name}.pdf")
|
||||
output_path = self.output_path / f"{user_name}.pdf"
|
||||
self._html_to_pdf(html, output_path)
|
||||
self._badge_count += 1
|
||||
logger.info(f"({self._badge_count}) Created: {output_path}, {user_name}, {seat_id}, {str(picture)[:10]}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user