ODT template into resources #11

Merged
artem.kokos merged 1 commits from templates into main 2026-01-25 12:29:59 +07:00
3 changed files with 9 additions and 7 deletions

View File

@@ -11,14 +11,13 @@ authors = [{ name = "Artem Kokos", email = "artem-kokos@mail.ru" }]
license = { text = "MIT" }
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: POSIX :: Linux",
"Environment :: Console",
]
requires-python = ">=3.8"
requires-python = ">=3.9"
dependencies = [
"python-redmine>=2.4.0",
"tabulate>=0.9.0",
@@ -42,9 +41,12 @@ redmine-reporter = "redmine_reporter.cli:main"
where = ["."]
include = ["redmine_reporter*"]
[tool.setuptools.package-data]
"redmine_reporter" = ["templates/template.odt"]
[tool.black]
line-length = 100
target-version = ['py38']
target-version = ['py39']
[tool.isort]
profile = "black"

View File

@@ -1,4 +1,5 @@
import os
from importlib import resources
from typing import List
from odf.opendocument import load
from odf.text import P
@@ -24,11 +25,10 @@ class ODTFormatter(Formatter):
"""
Форматирует данные в объект OpenDocument.
"""
template_path = "template.odt"
if not os.path.exists(template_path):
raise FileNotFoundError("Шаблон template.odt не найден...")
doc = load(template_path)
with resources.files("redmine_reporter").joinpath("templates", "template.odt").open("rb") as f:
doc = load(f)
para_style_name = "Standard"
# Заголовок