diff --git a/pyproject.toml b/pyproject.toml index 667c8d1..19d03ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/redmine_reporter/formatters/odt.py b/redmine_reporter/formatters/odt.py index 548aeff..83d6df0 100644 --- a/redmine_reporter/formatters/odt.py +++ b/redmine_reporter/formatters/odt.py @@ -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" # Заголовок diff --git a/template.odt b/redmine_reporter/templates/template.odt similarity index 100% rename from template.odt rename to redmine_reporter/templates/template.odt