def __init__(self, parent, standalone=False): # Translators: the title of the file associations dialog super().__init__(parent, title=_("Bookworm File Associations")) self.standalone = standalone icon_file = app_path(f"{app.name}.ico") if icon_file.exists(): self.SetIcon(wx.Icon(str(icon_file)))
def __init__(self, parent): super().__init__(parent) icon_file = app_path("bookshelf.ico") icon = wx.Icon() icon.LoadFile(os.fspath(icon_file)) self.SetIcon(icon) self.providers = BookshelfProvider.get_providers() self.menubar = wx.MenuBar() self.SetMenuBar(self.menubar) self.make_controls() self.CenterOnScreen() self.Maximize()
def get_ext_info(supported="*"): ficos_path = app_path("resources", "icons") doctypes = {} for cls in EBookReader.document_classes: for ext in cls.extensions: cext = ext.replace("*", "") if (supported == "*") or (cext in supported): icon = ficos_path.joinpath(cls.format + ".ico") icon = str(icon) if icon.exists() else None doctypes[cext] = (f"{app.prog_id}.{cls.format}", _(cls.name), icon) return doctypes
def __init__(self, language: str, non_breaking_prefix_file: str = None): """Create sentence splitter object. :param language: ISO 639-1 language code :param non_breaking_prefix_file: path to non-breaking prefix file """ if not regex.match( pattern=r"^[a-z][a-z]$", string=language, flags=regex.UNICODE): raise SentenceSplitterException( "Invalid language code: {}".format(language)) if non_breaking_prefix_file is None: non_breaking_prefix_file = app_path("resources", "non_breaking_prefixes", f"{language}.txt") if not Path(non_breaking_prefix_file).exists(): raise SentenceSplitterException( "Non-breaking prefix file for language '{}' was not found at path '{}'" .format(language, non_breaking_prefix_file)) self.__non_breaking_prefixes = dict() with open(non_breaking_prefix_file, mode="r", encoding="utf-8") as prefix_file: for line in prefix_file.readlines(): if "#NUMERIC_ONLY#" in line: prefix_type = SentenceSplitter.PrefixType.NUMERIC_ONLY else: prefix_type = SentenceSplitter.PrefixType.DEFAULT # Remove comments line = regex.sub( pattern=r"#.*", repl="", string=line, flags=regex.DOTALL | regex.UNICODE, ) line = line.strip() if not line: continue self.__non_breaking_prefixes[line] = prefix_type
def setFrameIcon(self): icon_file = app_path(f"{app.name}.ico") if icon_file.exists(): self.SetIcon(wx.Icon(str(icon_file)))
# coding: utf-8 import platform import clr import System from weakref import ref from pathlib import Path from bookworm import app from bookworm.paths import app_path from bookworm.speech.enumerations import EngineEvent, SynthState, RateSpec from bookworm.speech.engine import BaseSpeechEngine, VoiceInfo from bookworm.logger import logger try: _oc_dll = app_path("OcSpeechEngine.dll") if not app.is_frozen: _oc_dll = (Path.cwd() / "includes" / "sharp-onecore-synth" / "bin" / "Debug" / "OcSpeechEngine.dll") clr.AddReference(str(_oc_dll)) from OcSpeechEngine import OcSpeechEngine as _OnecoreEngine from .oc_utterance import OcSpeechUtterance _oc_available = True except: _oc_available = False log = logger.getChild(__name__) class OcSpeechEngine(BaseSpeechEngine):
def icon(self): ficos_path = app_path("resources", "icons") icon = ficos_path.joinpath(f"{self.format}.ico") return icon if icon.exists() else ficos_path.joinpath("file.ico")
def __getattr__(sound): if sound not in _sounds_cache: soundfile = app_path("resources", "soundfiles", f"{sound}.wav") _sounds_cache[sound] = SoundFile(str(soundfile)) return _sounds_cache[sound]
def supported_languages(): global _supported_lans if not _supported_lans: nbp_path = app_path("resources", "non_breaking_prefixes") _supported_lans = [file[:-4] for file in os.listdir(nbp_path)] return _supported_lans