diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-11-18 12:56:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-18 12:56:38 +0100 |
| commit | a66ae845f1f62ab6106c02663d2b191a35c9361f (patch) | |
| tree | d19fa099c96b6fdbfaf769c6245ac0d797748c85 /lib/utils | |
| parent | dde0444ac29f663579e70c1214ca4faa9862f0a6 (diff) | |
Print-pdf: simplify path detection (#3282)
* print-pdf: simplify path detection
* i18n: more cleaning up
* Version, License paths
Diffstat (limited to 'lib/utils')
| -rwxr-xr-x | lib/utils/paths.py | 13 | ||||
| -rwxr-xr-x | lib/utils/version.py | 19 |
2 files changed, 13 insertions, 19 deletions
diff --git a/lib/utils/paths.py b/lib/utils/paths.py index 10d72de9..2e9faa59 100755 --- a/lib/utils/paths.py +++ b/lib/utils/paths.py @@ -10,14 +10,19 @@ from os.path import dirname, realpath import appdirs -def get_bundled_dir(name): +def get_bundled_dir(name=None): if getattr(sys, 'frozen', None) is not None: if sys.platform == "darwin": - return realpath(os.path.join(sys._MEIPASS, "..", 'Resources', name)) + path = os.path.join(sys._MEIPASS, "..", 'Resources') else: - return realpath(os.path.join(sys._MEIPASS, "..", name)) + path = os.path.join(sys._MEIPASS, "..") else: - return realpath(os.path.join(dirname(realpath(__file__)), '..', '..', name)) + path = os.path.join(dirname(realpath(__file__)), '..', '..') + + if name is not None: + path = os.path.join(path, name) + + return realpath(path) def get_resource_dir(name): diff --git a/lib/utils/version.py b/lib/utils/version.py index eaa539b8..f4959a41 100755 --- a/lib/utils/version.py +++ b/lib/utils/version.py @@ -3,14 +3,14 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. -import sys -from os.path import isfile, join, realpath +from os.path import isfile, join from ..i18n import _ +from ..utils import get_bundled_dir def get_inkstitch_version(): - version = _get_source_file("VERSION") + version = join(get_bundled_dir(), "VERSION") if isfile(version): with open(version, 'r') as v: inkstitch_version = _("Ink/Stitch Version: %s") % v.readline() @@ -20,21 +20,10 @@ def get_inkstitch_version(): def get_inkstitch_license(): - license = _get_source_file("LICENSE") + license = join(get_bundled_dir(), "LICENSE") if isfile(license): with open(license, 'r') as lcs: license = lcs.read() else: license = "License: GNU GENERAL PUBLIC LICENSE\nVersion 3, 29 June 2007" return license - - -def _get_source_file(filename): - if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): - if sys.platform == "darwin": - source_file = realpath(join(sys._MEIPASS, "..", 'Resources', filename)) - else: - source_file = realpath(join(sys._MEIPASS, "..", filename)) - else: - source_file = realpath(join(realpath(__file__), "..", "..", "..", filename)) - return source_file |
