1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-18 18:07:37 +03:00

Made respath use pathlib paths

This commit is contained in:
A_D 2020-11-07 16:24:19 +02:00 committed by Athanasius
parent e44039cfdd
commit 6687dcbfef

12
l10n.py
View File

@ -6,6 +6,8 @@ import codecs
import locale import locale
import numbers import numbers
import os import os
from os import PathLike
import pathlib
import re import re
import sys import sys
from codecs import StreamReaderWriter from codecs import StreamReaderWriter
@ -197,18 +199,18 @@ class _Translations:
return names return names
def respath(self) -> str: # TODO: PathLike def respath(self) -> PathLike:
"""Path to localisation files.""" """Path to localisation files."""
if getattr(sys, 'frozen', False): if getattr(sys, 'frozen', False):
if platform == 'darwin': if platform == 'darwin':
return normpath(join(dirname(sys.executable), os.pardir, 'Resources')) return (pathlib.Path(sys.executable).parents[0] / os.pardir / 'Resources').resolve()
return join(dirname(sys.executable), LOCALISATION_DIR) return pathlib.Path(dirname(sys.executable)) / LOCALISATION_DIR
elif __file__: elif __file__:
return join(dirname(__file__), LOCALISATION_DIR) return pathlib.Path(__file__).parents[0] / LOCALISATION_DIR
return LOCALISATION_DIR return pathlib.Path(LOCALISATION_DIR)
def file(self, lang: str, plugin_path: Optional[str] = None) -> Optional[StreamReaderWriter]: def file(self, lang: str, plugin_path: Optional[str] = None) -> Optional[StreamReaderWriter]:
""" """