summaryrefslogtreecommitdiff
path: root/lib/extensions
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2024-11-18 12:56:38 +0100
committerGitHub <noreply@github.com>2024-11-18 12:56:38 +0100
commita66ae845f1f62ab6106c02663d2b191a35c9361f (patch)
treed19fa099c96b6fdbfaf769c6245ac0d797748c85 /lib/extensions
parentdde0444ac29f663579e70c1214ca4faa9862f0a6 (diff)
Print-pdf: simplify path detection (#3282)
* print-pdf: simplify path detection * i18n: more cleaning up * Version, License paths
Diffstat (limited to 'lib/extensions')
-rw-r--r--lib/extensions/print_pdf.py20
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py
index afef673d..3fb6a6a3 100644
--- a/lib/extensions/print_pdf.py
+++ b/lib/extensions/print_pdf.py
@@ -21,13 +21,14 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
from lxml import etree
from werkzeug.serving import make_server
-from .base import InkstitchExtension
from ..debug.debug import debug
from ..i18n import _, get_languages
from ..i18n import translation as inkstitch_translation
from ..stitch_plan import stitch_groups_to_stitch_plan
from ..svg import render_stitch_plan
from ..threads import ThreadCatalog
+from ..utils import get_resource_dir
+from .base import InkstitchExtension
def datetimeformat(value, format='%Y/%m/%d'):
@@ -111,13 +112,7 @@ class PrintPreviewServer(Thread):
self.__setup_app()
def __set_resources_path(self):
- if getattr(sys, 'frozen', False):
- if sys.platform == "darwin":
- self.resources_path = os.path.join(sys._MEIPASS, "..", 'Resources', 'print', 'resources')
- else:
- self.resources_path = os.path.join(sys._MEIPASS, 'print', 'resources')
- else:
- self.resources_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', '..', 'print', 'resources'))
+ self.resources_path = os.path.join(get_resource_dir('print'), 'resources')
def __setup_app(self): # noqa: C901
self.__set_resources_path()
@@ -313,14 +308,7 @@ class PrintInfoFrame(wx.Frame):
class Print(InkstitchExtension):
def build_environment(self):
- if getattr(sys, 'frozen', False):
- if sys.platform == "darwin":
- print_dir = os.path.join(sys._MEIPASS, "..", 'Resources', "print")
- else:
- print_dir = os.path.join(sys._MEIPASS, "print")
- else:
- print_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "print"))
-
+ print_dir = get_resource_dir('print')
template_dir = os.path.join(print_dir, "templates")
env = Environment(