mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
isosx -> ismacos
This commit is contained in:
parent
052af8c646
commit
13552bef07
@ -11,13 +11,13 @@ from contextlib import contextmanager
|
||||
|
||||
is64bit = platform.architecture()[0] == '64bit'
|
||||
iswindows = re.search('win(32|64)', sys.platform)
|
||||
isosx = 'darwin' in sys.platform
|
||||
ismacos = 'darwin' in sys.platform
|
||||
isfreebsd = 'freebsd' in sys.platform
|
||||
isnetbsd = 'netbsd' in sys.platform
|
||||
isdragonflybsd = 'dragonfly' in sys.platform
|
||||
isbsd = isnetbsd or isfreebsd or isdragonflybsd
|
||||
ishaiku = 'haiku1' in sys.platform
|
||||
islinux = not isosx and not iswindows and not isbsd and not ishaiku
|
||||
islinux = not ismacos and not iswindows and not isbsd and not ishaiku
|
||||
sys.setup_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
SRC = os.path.abspath(os.path.join(os.path.dirname(sys.setup_dir), 'src'))
|
||||
sys.path.insert(0, SRC)
|
||||
@ -160,7 +160,7 @@ class Command(object):
|
||||
self.real_user = os.environ.get('SUDO_USER', None)
|
||||
|
||||
def drop_privileges(self):
|
||||
if not islinux or isosx or isfreebsd:
|
||||
if not islinux or ismacos or isfreebsd:
|
||||
return
|
||||
if self.real_user is not None:
|
||||
self.info('Dropping privileges to those of', self.real_user+':',
|
||||
@ -171,7 +171,7 @@ class Command(object):
|
||||
os.seteuid(int(self.real_uid))
|
||||
|
||||
def regain_privileges(self):
|
||||
if not islinux or isosx or isfreebsd:
|
||||
if not islinux or ismacos or isfreebsd:
|
||||
return
|
||||
if os.geteuid() != 0 and self.orig_euid == 0:
|
||||
self.info('Trying to get root privileges')
|
||||
|
@ -8,8 +8,8 @@ __docformat__ = 'restructuredtext en'
|
||||
import textwrap, os, shlex, subprocess, glob, shutil, re, sys, json
|
||||
from collections import namedtuple
|
||||
|
||||
from setup import Command, islinux, isbsd, isfreebsd, isosx, ishaiku, SRC, iswindows, __version__
|
||||
isunix = islinux or isosx or isbsd or ishaiku
|
||||
from setup import Command, islinux, isbsd, isfreebsd, ismacos, ishaiku, SRC, iswindows, __version__
|
||||
isunix = islinux or ismacos or isbsd or ishaiku
|
||||
|
||||
py_lib = os.path.join(sys.prefix, 'libs', 'python%d%d.lib' % sys.version_info[:2])
|
||||
CompileCommand = namedtuple('CompileCommand', 'cmd src dest')
|
||||
@ -118,7 +118,7 @@ def parse_extension(ext):
|
||||
ans = ext.pop(k, default)
|
||||
if iswindows:
|
||||
ans = ext.pop('windows_' + k, ans)
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
ans = ext.pop('osx_' + k, ans)
|
||||
elif isbsd:
|
||||
ans = ext.pop('bsd_' + k, ans)
|
||||
@ -192,7 +192,7 @@ def init_env():
|
||||
ldflags.append('-lpython{}{}'.format(
|
||||
sysconfig.get_config_var('VERSION'), getattr(sys, 'abiflags', '')))
|
||||
|
||||
if isosx:
|
||||
if ismacos:
|
||||
cflags.append('-D_OSX')
|
||||
ldflags.extend('-bundle -undefined dynamic_lookup'.split())
|
||||
cflags.extend(['-fno-common', '-dynamic'])
|
||||
@ -420,7 +420,7 @@ class Build(Command):
|
||||
'calibre/headless/headless_backingstore.cpp',
|
||||
'calibre/headless/headless_integration.cpp',
|
||||
])
|
||||
if isosx:
|
||||
if ismacos:
|
||||
sources.extend(a(['calibre/headless/coretext_fontdatabase.mm']))
|
||||
else:
|
||||
headers.extend(a(['calibre/headless/fontconfig_database.h']))
|
||||
@ -462,7 +462,7 @@ class Build(Command):
|
||||
self.check_call([self.env.make] + ['-j%d'%(cpu_count or 1)])
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
if isosx:
|
||||
if ismacos:
|
||||
os.rename(self.j(self.d(target), 'libheadless.dylib'), self.j(self.d(target), 'headless.so'))
|
||||
|
||||
def get_sip_commands(self, ext):
|
||||
@ -524,7 +524,7 @@ class Build(Command):
|
||||
)
|
||||
for incdir in ext.inc_dirs:
|
||||
pro += '\nINCLUDEPATH += ' + incdir
|
||||
if not iswindows and not isosx:
|
||||
if not iswindows and not ismacos:
|
||||
# Ensure that only the init symbol is exported
|
||||
pro += '\nQMAKE_LFLAGS += -Wl,--version-script=%s.exp' % sip['target']
|
||||
with open(os.path.join(src_dir, sip['target'] + '.exp'), 'wb') as f:
|
||||
@ -539,7 +539,7 @@ class Build(Command):
|
||||
qmc = []
|
||||
if iswindows:
|
||||
qmc += ['-spec', qmakespec]
|
||||
fext = 'dll' if iswindows else 'dylib' if isosx else 'so'
|
||||
fext = 'dll' if iswindows else 'dylib' if ismacos else 'so'
|
||||
name = '%s%s.%s' % ('release/' if iswindows else 'lib', sip['target'], fext)
|
||||
try:
|
||||
os.chdir(src_dir)
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import os, subprocess, re, sys, sysconfig
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from setup import isfreebsd, isosx, iswindows, is64bit, islinux, ishaiku
|
||||
from setup import isfreebsd, ismacos, iswindows, is64bit, islinux, ishaiku
|
||||
is64bit
|
||||
|
||||
NMAKE = RC = msvc = MT = win_inc = win_lib = None
|
||||
@ -162,7 +162,7 @@ if iswindows:
|
||||
zlib_lib_dirs = [sw_lib_dir]
|
||||
podofo_inc = os.path.join(sw_inc_dir, 'podofo')
|
||||
podofo_lib = sw_lib_dir
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
sw = os.environ.get('SW', os.path.expanduser('~/sw'))
|
||||
sw_inc_dir = os.path.join(sw, 'include')
|
||||
sw_lib_dir = os.path.join(sw, 'lib')
|
||||
|
@ -6,7 +6,7 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from setup import Command, islinux, isosx, iswindows, SRC
|
||||
from setup import Command, islinux, ismacos, iswindows, SRC
|
||||
|
||||
TEST_MODULES = frozenset('srv db polish opf css docx cfi matcher icu smartypants build misc dbcli ebooks'.split())
|
||||
|
||||
@ -42,7 +42,7 @@ class TestImports(unittest.TestCase):
|
||||
if not iswindows:
|
||||
exclude_modules |= {'calibre.utils.iphlpapi', 'calibre.utils.open_with.windows', 'calibre.devices.winusb'}
|
||||
exclude_packages |= {'calibre.utils.winreg'}
|
||||
if not isosx:
|
||||
if not ismacos:
|
||||
exclude_modules.add('calibre.utils.open_with.osx')
|
||||
if not islinux:
|
||||
exclude_modules |= {
|
||||
|
@ -16,7 +16,7 @@ try:
|
||||
except EnvironmentError:
|
||||
os.chdir(os.path.expanduser('~'))
|
||||
|
||||
from calibre.constants import (iswindows, isosx, islinux, isfrozen,
|
||||
from calibre.constants import (iswindows, ismacos, islinux, isfrozen,
|
||||
isbsd, preferred_encoding, __appname__, __version__, __author__,
|
||||
win32event, win32api, winerror, fcntl,
|
||||
filesystem_encoding, plugins, config_dir)
|
||||
@ -94,7 +94,7 @@ def unicode_path(path, abs=False):
|
||||
|
||||
|
||||
def osx_version():
|
||||
if isosx:
|
||||
if ismacos:
|
||||
import platform
|
||||
src = platform.mac_ver()[0]
|
||||
m = re.match(r'(\d+)\.(\d+)\.(\d+)', src)
|
||||
@ -169,7 +169,7 @@ def setup_cli_handlers(logger, level):
|
||||
def load_library(name, cdll):
|
||||
if iswindows:
|
||||
return cdll.LoadLibrary(name)
|
||||
if isosx:
|
||||
if ismacos:
|
||||
name += '.dylib'
|
||||
if hasattr(sys, 'frameworks_dir'):
|
||||
return cdll.LoadLibrary(os.path.join(getattr(sys, 'frameworks_dir'), name))
|
||||
|
@ -17,16 +17,16 @@ Various run time constants.
|
||||
|
||||
_plat = sys.platform.lower()
|
||||
iswindows = 'win32' in _plat or 'win64' in _plat
|
||||
isosx = 'darwin' in _plat
|
||||
isnewosx = isosx and getattr(sys, 'new_app_bundle', False)
|
||||
ismacos = isosx = 'darwin' in _plat
|
||||
isnewosx = ismacos and getattr(sys, 'new_app_bundle', False)
|
||||
isfreebsd = 'freebsd' in _plat
|
||||
isnetbsd = 'netbsd' in _plat
|
||||
isdragonflybsd = 'dragonfly' in _plat
|
||||
isbsd = isfreebsd or isnetbsd or isdragonflybsd
|
||||
ishaiku = 'haiku1' in _plat
|
||||
islinux = not(iswindows or isosx or isbsd or ishaiku)
|
||||
islinux = not(iswindows or ismacos or isbsd or ishaiku)
|
||||
isfrozen = hasattr(sys, 'frozen')
|
||||
isunix = isosx or islinux or ishaiku
|
||||
isunix = ismacos or islinux or ishaiku
|
||||
isportable = hasenv('CALIBRE_PORTABLE_BUILD')
|
||||
ispy3 = sys.version_info.major > 2
|
||||
isxp = isoldvista = False
|
||||
@ -143,7 +143,7 @@ def _get_cache_dir():
|
||||
candidate = os.path.join(w.special_folder_path(w.CSIDL_LOCAL_APPDATA), '%s-cache'%__appname__)
|
||||
except ValueError:
|
||||
return confcache
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
candidate = os.path.join(os.path.expanduser('~/Library/Caches'), __appname__)
|
||||
else:
|
||||
candidate = getenv('XDG_CACHE_HOME', '~/.cache')
|
||||
@ -203,10 +203,10 @@ class Plugins(collections.Mapping):
|
||||
]
|
||||
if iswindows:
|
||||
plugins.extend(['winutil', 'wpd', 'winfonts'])
|
||||
if isosx:
|
||||
if ismacos:
|
||||
plugins.append('usbobserver')
|
||||
plugins.append('cocoa')
|
||||
if isfreebsd or ishaiku or islinux or isosx:
|
||||
if isfreebsd or ishaiku or islinux or ismacos:
|
||||
plugins.append('libusb')
|
||||
plugins.append('libmtp')
|
||||
self.plugins = frozenset(plugins)
|
||||
@ -269,7 +269,7 @@ elif iswindows:
|
||||
if not config_dir or not os.access(config_dir, os.W_OK|os.X_OK):
|
||||
config_dir = os.path.expanduser('~')
|
||||
config_dir = os.path.join(config_dir, 'calibre')
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
config_dir = os.path.expanduser('~/Library/Preferences/calibre')
|
||||
else:
|
||||
bdir = os.path.abspath(os.path.expanduser(getenv('XDG_CONFIG_HOME', '~/.config')))
|
||||
|
@ -4,14 +4,14 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, sys, zipfile, importlib
|
||||
|
||||
from calibre.constants import numeric_version, iswindows, isosx
|
||||
from calibre.constants import numeric_version, iswindows, ismacos
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from polyglot.builtins import unicode_type
|
||||
|
||||
platform = 'linux'
|
||||
if iswindows:
|
||||
platform = 'windows'
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
platform = 'osx'
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ from contextlib import contextmanager
|
||||
from functools import partial
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import iswindows, isosx, filesystem_encoding
|
||||
from calibre.constants import iswindows, ismacos, filesystem_encoding
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ def metadata_extensions():
|
||||
return _metadata_extensions
|
||||
|
||||
|
||||
if iswindows or isosx:
|
||||
if iswindows or ismacos:
|
||||
unicode_listdir = os.listdir
|
||||
else:
|
||||
def unicode_listdir(root):
|
||||
|
@ -8,7 +8,7 @@ __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import os, tempfile, shutil, errno, time, atexit
|
||||
from threading import Thread
|
||||
|
||||
from calibre.constants import isosx, plugins
|
||||
from calibre.constants import ismacos, plugins
|
||||
from calibre.ptempfile import remove_dir
|
||||
from calibre.utils.filenames import remove_dir_if_empty
|
||||
from calibre.utils.recycle_bin import delete_tree, delete_file
|
||||
@ -34,7 +34,7 @@ class DeleteService(Thread):
|
||||
def __init__(self):
|
||||
Thread.__init__(self)
|
||||
self.requests = Queue()
|
||||
if isosx:
|
||||
if ismacos:
|
||||
plugins['cocoa'][0].enable_cocoa_multithreading()
|
||||
|
||||
def shutdown(self, timeout=20):
|
||||
|
@ -181,7 +181,7 @@ def print_basic_debug_info(out=None):
|
||||
out = sys.stdout
|
||||
out = functools.partial(prints, file=out)
|
||||
import platform
|
||||
from calibre.constants import (__appname__, get_version, isportable, isosx,
|
||||
from calibre.constants import (__appname__, get_version, isportable, ismacos,
|
||||
isfrozen, is64bit)
|
||||
from calibre.utils.localization import set_translators
|
||||
out(__appname__, get_version(), 'Portable' if isportable else '',
|
||||
@ -200,7 +200,7 @@ def print_basic_debug_info(out=None):
|
||||
try:
|
||||
if iswindows:
|
||||
out('Windows:', platform.win32_ver())
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
out('OSX:', platform.mac_ver())
|
||||
else:
|
||||
out('Linux:', platform.linux_distribution())
|
||||
|
@ -72,7 +72,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
from calibre.customize.ui import device_plugins, disabled_device_plugins
|
||||
from calibre.debug import print_basic_debug_info
|
||||
from calibre.devices.scanner import DeviceScanner
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre import prints
|
||||
from polyglot.io import PolyglotStringIO
|
||||
oldo, olde = sys.stdout, sys.stderr
|
||||
@ -108,7 +108,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
out(pprint.pformat(devices))
|
||||
|
||||
ioreg = None
|
||||
if isosx:
|
||||
if ismacos:
|
||||
from calibre.devices.usbms.device import Device
|
||||
mount = '\n'.join(repr(x) for x in Device.osx_run_mount().splitlines())
|
||||
drives = pprint.pformat(Device.osx_get_usb_drives())
|
||||
|
@ -11,7 +11,7 @@ from collections import namedtuple
|
||||
from functools import partial
|
||||
|
||||
from calibre import prints, as_unicode, force_unicode
|
||||
from calibre.constants import plugins, islinux, isosx
|
||||
from calibre.constants import plugins, islinux, ismacos
|
||||
from calibre.ptempfile import SpooledTemporaryFile
|
||||
from calibre.devices.errors import OpenFailed, DeviceError, BlacklistedDevice, OpenActionNeeded
|
||||
from calibre.devices.mtp.base import MTPDeviceBase, synchronous, debug
|
||||
@ -51,7 +51,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
||||
if islinux:
|
||||
from calibre.devices.mtp.unix.sysfs import MTPDetect
|
||||
self._is_device_mtp = MTPDetect()
|
||||
if isosx and 'osx' in self.supported_platforms:
|
||||
if ismacos and 'osx' in self.supported_platforms:
|
||||
self.usbobserver, err = plugins['usbobserver']
|
||||
if err:
|
||||
raise RuntimeError(err)
|
||||
|
@ -11,7 +11,7 @@ from collections import namedtuple
|
||||
from threading import Lock
|
||||
|
||||
from calibre import prints, as_unicode
|
||||
from calibre.constants import (iswindows, isosx, plugins, islinux, isfreebsd,
|
||||
from calibre.constants import (iswindows, ismacos, plugins, islinux, isfreebsd,
|
||||
isnetbsd)
|
||||
from polyglot.builtins import range
|
||||
|
||||
@ -172,7 +172,7 @@ if islinux:
|
||||
linux_scanner = LinuxScanner()
|
||||
|
||||
libusb_scanner = LibUSBScanner()
|
||||
if False and isosx:
|
||||
if False and ismacos:
|
||||
# Apparently libusb causes mem leaks on some Macs and hangs on others and
|
||||
# works on a few. OS X users will just have to live without MTP support.
|
||||
# See https://bugs.launchpad.net/calibre/+bug/1044706
|
||||
@ -196,7 +196,7 @@ class DeviceScanner(object):
|
||||
def __init__(self, *args):
|
||||
if iswindows:
|
||||
from calibre.devices.winusb import scan_usb_devices as win_scanner
|
||||
self.scanner = (win_scanner if iswindows else osx_scanner if isosx else
|
||||
self.scanner = (win_scanner if iswindows else osx_scanner if ismacos else
|
||||
freebsd_scanner if isfreebsd else netbsd_scanner if isnetbsd
|
||||
else linux_scanner if islinux else libusb_scanner)
|
||||
if self.scanner is None:
|
||||
|
@ -21,11 +21,11 @@ from calibre.constants import DEBUG
|
||||
from calibre.devices.interface import DevicePlugin
|
||||
from calibre.devices.errors import DeviceError
|
||||
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
||||
from calibre.constants import iswindows, islinux, isosx, isfreebsd, plugins
|
||||
from calibre.constants import iswindows, islinux, ismacos, isfreebsd, plugins
|
||||
from calibre.utils.filenames import ascii_filename as sanitize
|
||||
from polyglot.builtins import iteritems, string_or_bytes, map
|
||||
|
||||
if isosx:
|
||||
if ismacos:
|
||||
usbobserver, usbobserver_err = plugins['usbobserver']
|
||||
osx_sanitize_name_pat = re.compile(r'[.-]')
|
||||
|
||||
@ -819,7 +819,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
self.open_freebsd()
|
||||
if iswindows:
|
||||
self.open_windows()
|
||||
if isosx:
|
||||
if ismacos:
|
||||
try:
|
||||
self.open_osx()
|
||||
except DeviceError:
|
||||
@ -891,7 +891,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
self.eject_windows()
|
||||
except:
|
||||
pass
|
||||
if isosx:
|
||||
if ismacos:
|
||||
try:
|
||||
self.eject_osx()
|
||||
except:
|
||||
|
@ -10,7 +10,7 @@ import re
|
||||
from struct import pack
|
||||
from io import BytesIO
|
||||
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre.ebooks.mobi.utils import (utf8_text, to_base)
|
||||
from calibre.utils.localization import lang_as_iso639_1
|
||||
from calibre.ebooks.metadata import authors_to_sort_string
|
||||
@ -154,7 +154,7 @@ def build_exth(metadata, prefer_author_sort=False, is_periodical=False,
|
||||
nrecs += 1
|
||||
|
||||
if be_kindlegen2:
|
||||
mv = 200 if iswindows else 202 if isosx else 201
|
||||
mv = 200 if iswindows else 202 if ismacos else 201
|
||||
vals = {204:mv, 205:2, 206:9, 207:0}
|
||||
elif is_periodical:
|
||||
# Pretend to be amazon's super secret periodical generator
|
||||
|
@ -10,7 +10,7 @@ import subprocess
|
||||
import sys
|
||||
|
||||
from calibre import CurrentDir, prints, xml_replace_entities
|
||||
from calibre.constants import isbsd, islinux, isosx, iswindows
|
||||
from calibre.constants import isbsd, islinux, ismacos, iswindows
|
||||
from calibre.ebooks import ConversionError, DRMError
|
||||
from calibre.ebooks.chardet import xml_to_unicode
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
@ -26,7 +26,7 @@ def popen(cmd, **kw):
|
||||
return subprocess.Popen(cmd, **kw)
|
||||
|
||||
|
||||
if isosx and hasattr(sys, 'frameworks_dir'):
|
||||
if ismacos and hasattr(sys, 'frameworks_dir'):
|
||||
base = os.path.join(os.path.dirname(sys.frameworks_dir), 'utils.app', 'Contents', 'MacOS')
|
||||
PDFTOHTML = os.path.join(base, PDFTOHTML)
|
||||
if iswindows and hasattr(sys, 'frozen'):
|
||||
|
@ -25,7 +25,7 @@ from PyQt5.QtWidgets import QStyle # Gives a nicer error message than import fr
|
||||
from calibre import as_unicode, prints
|
||||
from calibre.constants import (
|
||||
DEBUG, __appname__ as APP_UID, __version__, config_dir, filesystem_encoding,
|
||||
is_running_from_develop, isbsd, isfrozen, islinux, isosx, iswindows, isxp,
|
||||
is_running_from_develop, isbsd, isfrozen, islinux, ismacos, iswindows, isxp,
|
||||
plugins, plugins_loc
|
||||
)
|
||||
from calibre.ebooks.metadata import MetaInformation
|
||||
@ -69,7 +69,7 @@ native_menubar_defaults = {
|
||||
|
||||
def create_defs():
|
||||
defs = gprefs.defaults
|
||||
if isosx:
|
||||
if ismacos:
|
||||
defs['action-layout-menubar'] = native_menubar_defaults['action-layout-menubar']
|
||||
defs['action-layout-menubar-device'] = native_menubar_defaults['action-layout-menubar-device']
|
||||
defs['action-layout-toolbar'] = (
|
||||
@ -147,7 +147,7 @@ def create_defs():
|
||||
defs['blocked_auto_formats'] = []
|
||||
defs['auto_add_auto_convert'] = True
|
||||
defs['auto_add_everything'] = False
|
||||
defs['ui_style'] = 'calibre' if iswindows or isosx else 'system'
|
||||
defs['ui_style'] = 'calibre' if iswindows or ismacos else 'system'
|
||||
defs['tag_browser_old_look'] = False
|
||||
defs['tag_browser_hide_empty_categories'] = False
|
||||
defs['tag_browser_always_autocollapse'] = False
|
||||
@ -663,7 +663,7 @@ if iswindows and 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ:
|
||||
from calibre.gui2.win_file_dialogs import is_ok as has_windows_file_dialog_helper
|
||||
has_windows_file_dialog_helper = has_windows_file_dialog_helper()
|
||||
has_linux_file_dialog_helper = False
|
||||
if not iswindows and not isosx and 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ and getattr(sys, 'frozen', False):
|
||||
if not iswindows and not ismacos and 'CALIBRE_NO_NATIVE_FILEDIALOGS' not in os.environ and getattr(sys, 'frozen', False):
|
||||
has_linux_file_dialog_helper = check_for_linux_native_dialogs()
|
||||
|
||||
if has_windows_file_dialog_helper:
|
||||
@ -883,7 +883,7 @@ class Application(QApplication):
|
||||
self.pi, pi_err = plugins['progress_indicator']
|
||||
if pi_err:
|
||||
raise RuntimeError('Failed to load the progress_indicator C extension, with error: {}'.format(pi_err))
|
||||
if not isosx and not headless:
|
||||
if not ismacos and not headless:
|
||||
# On OS X high dpi scaling is turned on automatically by the OS, so we dont need to set it explicitly
|
||||
setup_hidpi()
|
||||
QApplication.setOrganizationName('calibre-ebook.com')
|
||||
@ -897,7 +897,7 @@ class Application(QApplication):
|
||||
sh = self.styleHints()
|
||||
if hasattr(sh, 'setShowShortcutsInContextMenus'):
|
||||
sh.setShowShortcutsInContextMenus(True)
|
||||
if isosx:
|
||||
if ismacos:
|
||||
plugins['cocoa'][0].disable_cocoa_ui_elements()
|
||||
self.setAttribute(Qt.AA_UseHighDpiPixmaps)
|
||||
self.setAttribute(Qt.AA_SynthesizeTouchForUnhandledMouseEvents, False)
|
||||
@ -929,7 +929,7 @@ class Application(QApplication):
|
||||
if s is not None:
|
||||
font.setStretch(s)
|
||||
QApplication.setFont(font)
|
||||
if not isosx and not iswindows:
|
||||
if not ismacos and not iswindows:
|
||||
# Qt 5.10.1 on Linux resets the global font on first event loop tick.
|
||||
# So workaround it by setting the font once again in a timer.
|
||||
font_from_prefs = self.font()
|
||||
@ -947,7 +947,7 @@ class Application(QApplication):
|
||||
self._file_open_paths = []
|
||||
self._file_open_lock = RLock()
|
||||
|
||||
if not isosx:
|
||||
if not ismacos:
|
||||
# OS X uses a native color dialog that does not support custom
|
||||
# colors
|
||||
self.color_prefs = color_prefs
|
||||
@ -975,7 +975,7 @@ class Application(QApplication):
|
||||
# Qt 5 bug: https://bugreports.qt-project.org/browse/QTBUG-41125
|
||||
self.aboutToQuit.connect(self.flush_clipboard)
|
||||
|
||||
if isosx:
|
||||
if ismacos:
|
||||
cocoa, err = plugins['cocoa']
|
||||
if err:
|
||||
raise RuntimeError('Failed to load cocoa plugin with error: {}'.format(err))
|
||||
@ -1038,7 +1038,7 @@ class Application(QApplication):
|
||||
self.set_palette(dark_palette())
|
||||
|
||||
def setup_styles(self, force_calibre_style):
|
||||
if iswindows or isosx:
|
||||
if iswindows or ismacos:
|
||||
using_calibre_style = gprefs['ui_style'] != 'system'
|
||||
else:
|
||||
using_calibre_style = os.environ.get('CALIBRE_USE_SYSTEM_THEME', '0') == '0'
|
||||
@ -1047,7 +1047,7 @@ class Application(QApplication):
|
||||
if using_calibre_style:
|
||||
use_dark_palette = False
|
||||
if 'CALIBRE_USE_DARK_PALETTE' in os.environ:
|
||||
if not isosx:
|
||||
if not ismacos:
|
||||
use_dark_palette = os.environ['CALIBRE_USE_DARK_PALETTE'] != '0'
|
||||
else:
|
||||
if iswindows:
|
||||
@ -1087,7 +1087,7 @@ class Application(QApplication):
|
||||
return
|
||||
self.is_dark_theme = is_dark_theme()
|
||||
self.setProperty('is_dark_theme', self.is_dark_theme)
|
||||
if isosx and self.is_dark_theme and self.using_calibre_style:
|
||||
if ismacos and self.is_dark_theme and self.using_calibre_style:
|
||||
QTimer.singleShot(0, self.fix_combobox_text_color)
|
||||
if self.using_calibre_style:
|
||||
ss = 'QTabBar::tab:selected { font-style: italic }\n\n'
|
||||
@ -1132,7 +1132,7 @@ class Application(QApplication):
|
||||
v = pcache[v]
|
||||
icon_map[getattr(QStyle, 'SP_'+k)] = v
|
||||
transient_scroller = 0
|
||||
if isosx:
|
||||
if ismacos:
|
||||
transient_scroller = plugins['cocoa'][0].transient_scroller()
|
||||
icon_map[QStyle.SP_CustomBase + 1] = I('close-for-light-theme.png')
|
||||
icon_map[QStyle.SP_CustomBase + 2] = I('close-for-dark-theme.png')
|
||||
@ -1215,7 +1215,7 @@ def sanitize_env_vars():
|
||||
env_vars = {'LD_LIBRARY_PATH':'/lib'}
|
||||
elif iswindows:
|
||||
env_vars = {}
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
env_vars = {k:None for k in (
|
||||
'FONTCONFIG_FILE FONTCONFIG_PATH SSL_CERT_FILE').split()}
|
||||
else:
|
||||
@ -1300,10 +1300,10 @@ def ensure_app(headless=True):
|
||||
with _ea_lock:
|
||||
if _store_app is None and QApplication.instance() is None:
|
||||
args = sys.argv[:1]
|
||||
has_headless = isosx or islinux or isbsd
|
||||
has_headless = ismacos or islinux or isbsd
|
||||
if headless and has_headless:
|
||||
args += ['-platformpluginpath', plugins_loc, '-platform', 'headless']
|
||||
if isosx:
|
||||
if ismacos:
|
||||
os.environ['QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM'] = '1'
|
||||
if headless and iswindows:
|
||||
QApplication.setAttribute(Qt.AA_UseSoftwareOpenGL, True)
|
||||
|
@ -13,7 +13,7 @@ from PyQt5.Qt import (QToolButton, QAction, QIcon, QObject, QMenu,
|
||||
QKeySequence)
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import Dispatcher
|
||||
from calibre.gui2.keyboard import NameConflict
|
||||
from polyglot.builtins import unicode_type, string_or_bytes
|
||||
@ -201,7 +201,7 @@ class InterfaceAction(QObject):
|
||||
QKeySequence.PortableText) for key in keys])
|
||||
else:
|
||||
self.shortcut_action_for_context_menu = shortcut_action
|
||||
if isosx:
|
||||
if ismacos:
|
||||
# In Qt 5 keyboard shortcuts dont work unless the
|
||||
# action is explicitly added to the main window
|
||||
self.gui.addAction(shortcut_action)
|
||||
|
@ -18,7 +18,7 @@ from PyQt5.Qt import (
|
||||
QScrollArea, QVBoxLayout, Qt, QListWidgetItem, QListWidget, QSize)
|
||||
|
||||
from calibre import as_unicode
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2 import (error_dialog, Dispatcher, warning_dialog, gprefs,
|
||||
info_dialog, choose_dir)
|
||||
@ -374,7 +374,7 @@ class CopyToLibraryAction(InterfaceAction):
|
||||
self.menu.addAction(_('Choose library...'), self.choose_library)
|
||||
|
||||
self.qaction.setVisible(bool(locations))
|
||||
if isosx:
|
||||
if ismacos:
|
||||
# The cloned action has to have its menu updated
|
||||
self.qaction.changed.emit()
|
||||
|
||||
|
@ -12,7 +12,7 @@ from collections import Counter
|
||||
|
||||
from PyQt5.Qt import QObject, QTimer, QModelIndex
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import error_dialog, question_dialog
|
||||
from calibre.gui2.dialogs.delete_matching_from_device import DeleteMatchingFromDeviceDialog
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
@ -87,7 +87,7 @@ class MultiDeleter(QObject): # {{{
|
||||
class DeleteAction(InterfaceAction):
|
||||
|
||||
name = 'Remove Books'
|
||||
action_spec = (_('Remove books'), 'remove_books.png', _('Delete books'), 'Backspace' if isosx else 'Del')
|
||||
action_spec = (_('Remove books'), 'remove_books.png', _('Delete books'), 'Backspace' if ismacos else 'Del')
|
||||
action_type = 'current'
|
||||
action_add_menu = True
|
||||
action_menu_clone_qaction = _('Remove selected books')
|
||||
|
@ -13,7 +13,7 @@ from PyQt5.Qt import QIcon, Qt
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.preferences.main import Preferences
|
||||
from calibre.gui2 import error_dialog, show_restart_warning
|
||||
from calibre.constants import DEBUG, isosx
|
||||
from calibre.constants import DEBUG, ismacos
|
||||
|
||||
|
||||
class PreferencesAction(InterfaceAction):
|
||||
@ -26,7 +26,7 @@ class PreferencesAction(InterfaceAction):
|
||||
def genesis(self):
|
||||
pm = self.qaction.menu()
|
||||
cm = partial(self.create_menu_action, pm)
|
||||
if isosx:
|
||||
if ismacos:
|
||||
pm.addAction(QIcon(I('config.png')), _('Preferences'), self.do_config)
|
||||
cm('welcome wizard', _('Run Welcome wizard'),
|
||||
icon='wizard.png', triggered=self.gui.run_wizard)
|
||||
|
@ -12,7 +12,7 @@ from PyQt5.Qt import (QDialog, QVBoxLayout, QHBoxLayout, QRadioButton, QFrame,
|
||||
QPushButton, QLabel, QGroupBox, QGridLayout, QIcon, QSize, QTimer)
|
||||
|
||||
from calibre import as_unicode
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import error_dialog, question_dialog, open_local_file, gprefs
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.ptempfile import (PersistentTemporaryDirectory,
|
||||
@ -255,7 +255,7 @@ class UnpackBook(QDialog):
|
||||
self.reject()
|
||||
|
||||
def cleanup(self):
|
||||
if isosx and self._exploded:
|
||||
if ismacos and self._exploded:
|
||||
try:
|
||||
import appscript
|
||||
self.finder = appscript.app('Finder')
|
||||
|
@ -11,7 +11,7 @@ from functools import partial
|
||||
|
||||
from PyQt5.Qt import Qt, QAction, pyqtSignal
|
||||
|
||||
from calibre.constants import isosx, iswindows, plugins
|
||||
from calibre.constants import ismacos, iswindows, plugins
|
||||
from calibre.gui2 import (
|
||||
error_dialog, Dispatcher, question_dialog, config, open_local_file,
|
||||
info_dialog, elided_text)
|
||||
@ -135,7 +135,7 @@ class ViewAction(InterfaceAction):
|
||||
try:
|
||||
if internal:
|
||||
args = [viewer]
|
||||
if isosx and 'ebook' in viewer:
|
||||
if ismacos and 'ebook' in viewer:
|
||||
args.append('--raise-window')
|
||||
|
||||
if name is not None:
|
||||
@ -247,7 +247,7 @@ class ViewAction(InterfaceAction):
|
||||
for i, row in enumerate(rows):
|
||||
path = self.gui.library_view.model().db.abspath(row.row())
|
||||
open_local_file(path)
|
||||
if isosx and i < len(rows) - 1:
|
||||
if ismacos and i < len(rows) - 1:
|
||||
time.sleep(0.1) # Finder cannot handle multiple folder opens
|
||||
|
||||
def view_folder_for_id(self, id_):
|
||||
|
@ -14,7 +14,7 @@ from polyglot.builtins import iteritems, map, unicode_type, string_or_bytes
|
||||
from PyQt5.Qt import QObject, Qt, pyqtSignal
|
||||
|
||||
from calibre import prints, as_unicode
|
||||
from calibre.constants import DEBUG, iswindows, isosx, filesystem_encoding
|
||||
from calibre.constants import DEBUG, iswindows, ismacos, filesystem_encoding
|
||||
from calibre.customize.ui import run_plugins_on_postimport, run_plugins_on_postadd
|
||||
from calibre.db.adding import find_books_in_directory, compile_rule
|
||||
from calibre.db.utils import find_identical_books
|
||||
@ -134,7 +134,7 @@ class Adder(QObject):
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if iswindows or isosx:
|
||||
if iswindows or ismacos:
|
||||
def find_files(root):
|
||||
for dirpath, dirnames, filenames in os.walk(root):
|
||||
for files in find_books_in_directory(dirpath, self.single_book_per_directory, compiled_rules=compiled_rules):
|
||||
|
@ -15,7 +15,7 @@ try:
|
||||
except ImportError:
|
||||
import sip
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import gprefs, native_menubar_defaults, config
|
||||
from calibre.gui2.throbber import ThrobbingButton
|
||||
from polyglot.builtins import itervalues, unicode_type, map, range
|
||||
@ -334,7 +334,7 @@ class MenuAction(QAction): # {{{
|
||||
# MenuBar {{{
|
||||
|
||||
|
||||
if isosx:
|
||||
if ismacos:
|
||||
# On OS X we need special handling for the application global menu bar and
|
||||
# the context menus, since Qt does not handle dynamic menus or menus in
|
||||
# which the same action occurs in more than one place.
|
||||
@ -617,11 +617,11 @@ class AdaptMenuBarForDialog(object):
|
||||
self.menu_bar = menu_bar
|
||||
|
||||
def __enter__(self):
|
||||
if isosx and self.menu_bar.is_native_menubar:
|
||||
if ismacos and self.menu_bar.is_native_menubar:
|
||||
self.menu_bar.adapt_for_dialog(True)
|
||||
|
||||
def __exit__(self, *a):
|
||||
if isosx and self.menu_bar.is_native_menubar:
|
||||
if ismacos and self.menu_bar.is_native_menubar:
|
||||
self.menu_bar.adapt_for_dialog(False)
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt5.Qt import QWidget, QListWidgetItem, Qt, QVBoxLayout, QLabel, QListWidget
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import gprefs
|
||||
from calibre.gui2.ui import get_gui
|
||||
from polyglot.builtins import unicode_type, range
|
||||
@ -53,7 +53,7 @@ class PluginWidget(QWidget):
|
||||
l.addWidget(la)
|
||||
self.db_fields.setDragEnabled(True)
|
||||
self.db_fields.setDragDropMode(QListWidget.InternalMove)
|
||||
self.db_fields.setDefaultDropAction(Qt.CopyAction if isosx else Qt.MoveAction)
|
||||
self.db_fields.setDefaultDropAction(Qt.CopyAction if ismacos else Qt.MoveAction)
|
||||
self.db_fields.setAlternatingRowColors(True)
|
||||
self.db_fields.setObjectName("db_fields")
|
||||
|
||||
|
@ -15,7 +15,7 @@ try:
|
||||
except ImportError:
|
||||
import sip
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.utils.icu import sort_key, primary_startswith, primary_contains
|
||||
from calibre.gui2.widgets import EnComboBox, LineEditECM
|
||||
from calibre.utils.config import tweaks
|
||||
@ -250,7 +250,7 @@ class Completer(QListView): # {{{
|
||||
self.hide()
|
||||
if e.isAccepted():
|
||||
return True
|
||||
elif isosx and etype == e.InputMethodQuery and e.queries() == (Qt.ImHints | Qt.ImEnabled) and self.isVisible():
|
||||
elif ismacos and etype == e.InputMethodQuery and e.queries() == (Qt.ImHints | Qt.ImEnabled) and self.isVisible():
|
||||
# In Qt 5 the Esc key causes this event and the line edit does not
|
||||
# handle it, which causes the parent dialog to be closed
|
||||
# See https://bugreports.qt-project.org/browse/QTBUG-41806
|
||||
|
@ -10,7 +10,7 @@ import time, sys, weakref
|
||||
from PyQt5.Qt import (
|
||||
QObject, QMenuBar, QAction, QEvent, QSystemTrayIcon, QApplication, Qt)
|
||||
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from polyglot.builtins import range, unicode_type
|
||||
|
||||
UNITY_WINDOW_REGISTRAR = ('com.canonical.AppMenu.Registrar', '/com/canonical/AppMenu/Registrar', 'com.canonical.AppMenu.Registrar')
|
||||
@ -117,7 +117,7 @@ class Factory(QObject):
|
||||
def __init__(self, app_id=None):
|
||||
QObject.__init__(self)
|
||||
self.app_id = app_id or QApplication.instance().applicationName() or 'unknown_application'
|
||||
if iswindows or isosx:
|
||||
if iswindows or ismacos:
|
||||
self.dbus = None
|
||||
else:
|
||||
try:
|
||||
@ -228,7 +228,7 @@ class Factory(QObject):
|
||||
self.prune_dead_refs()
|
||||
self.status_notifiers.append(weakref.ref(ans))
|
||||
return ans
|
||||
if iswindows or isosx:
|
||||
if iswindows or ismacos:
|
||||
return QSystemTrayIcon(parent)
|
||||
|
||||
def bus_disconnected(self):
|
||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (Qt, QUrl, QFrame, QVBoxLayout, QLabel, QBrush, QTextEdit,
|
||||
QFont, QPixmap, QSize, QLineEdit)
|
||||
|
||||
from calibre import browser, prints
|
||||
from calibre.constants import numeric_version, iswindows, isosx, DEBUG, __appname__, __version__
|
||||
from calibre.constants import numeric_version, iswindows, ismacos, DEBUG, __appname__, __version__
|
||||
from calibre.customize.ui import (
|
||||
initialized_plugins, is_disabled, remove_plugin, add_plugin, enable_plugin, disable_plugin,
|
||||
NameConflict, has_external_plugins)
|
||||
@ -229,7 +229,7 @@ class DisplayPlugin(object):
|
||||
def is_valid_platform(self):
|
||||
if iswindows:
|
||||
return 'windows' in self.platforms
|
||||
if isosx:
|
||||
if ismacos:
|
||||
return 'osx' in self.platforms
|
||||
return 'linux' in self.platforms
|
||||
|
||||
|
@ -14,7 +14,7 @@ from PyQt5.Qt import (
|
||||
QToolButton, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from calibre.constants import __appname__, get_version, isosx
|
||||
from calibre.constants import __appname__, get_version, ismacos
|
||||
from calibre.customize.ui import find_plugin
|
||||
from calibre.gui2 import config, error_dialog, gprefs, is_widescreen, open_url
|
||||
from calibre.gui2.book_details import BookDetails
|
||||
@ -618,7 +618,7 @@ class LayoutMixin(object): # {{{
|
||||
button = self.search_bar_button
|
||||
self.layout_buttons.append(button)
|
||||
button.setVisible(False)
|
||||
if isosx and stylename != 'Calibre':
|
||||
if ismacos and stylename != 'Calibre':
|
||||
button.setStyleSheet('''
|
||||
QToolButton { background: none; border:none; padding: 0px; }
|
||||
QToolButton:checked { background: rgba(0, 0, 0, 25%); }
|
||||
|
@ -16,7 +16,7 @@ from PyQt5.Qt import QCoreApplication, QIcon, QObject, QTimer
|
||||
from calibre import force_unicode, plugins, prints
|
||||
from calibre.constants import (
|
||||
DEBUG, MAIN_APP_UID, __appname__, filesystem_encoding, get_portable_base,
|
||||
islinux, isosx, iswindows
|
||||
islinux, ismacos, iswindows
|
||||
)
|
||||
from calibre.gui2 import (
|
||||
Application, choose_dir, error_dialog, gprefs, initialize_file_icon_provider,
|
||||
@ -382,7 +382,7 @@ def run_gui(opts, args, listener, app, gui_debug=None):
|
||||
wizard().exec_()
|
||||
dynamic.set('welcome_wizard_was_run', True)
|
||||
from calibre.gui2.ui import Main
|
||||
if isosx:
|
||||
if ismacos:
|
||||
actions = tuple(Main.create_application_menubar())
|
||||
else:
|
||||
actions = tuple(Main.get_menubar_actions())
|
||||
@ -446,7 +446,7 @@ def cant_start(msg=_('If you are sure it is not running')+', ',
|
||||
listener_failed=False):
|
||||
base = '<p>%s</p><p>%s %s'
|
||||
where = __appname__ + ' '+_('may be running in the system tray, in the')+' '
|
||||
if isosx:
|
||||
if ismacos:
|
||||
where += _('upper right region of the screen.')
|
||||
else:
|
||||
where += _('lower right region of the screen.')
|
||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton, QAppli
|
||||
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem, QInputDialog,
|
||||
QSizePolicy, QFrame, QSize, QKeySequence, QMenu, QShortcut, QDialog)
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2.dialogs.confirm_delete import confirm
|
||||
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
||||
from calibre.gui2 import error_dialog, gprefs, pixmap_to_data
|
||||
@ -158,7 +158,7 @@ class MetadataSingleDialogBase(QDialog):
|
||||
'change author sort from red to green. There is a menu of '
|
||||
'functions available under this button. Click and hold '
|
||||
'on the button to see it.') + '</p>')
|
||||
if isosx:
|
||||
if ismacos:
|
||||
# Workaround for https://bugreports.qt-project.org/browse/QTBUG-41017
|
||||
class Menu(QMenu):
|
||||
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import time
|
||||
from calibre import prints
|
||||
from calibre.constants import islinux, isosx, get_osx_version, DEBUG, plugins
|
||||
from calibre.constants import islinux, ismacos, get_osx_version, DEBUG, plugins
|
||||
from polyglot.builtins import unicode_type
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ class QtNotifier(Notifier):
|
||||
try:
|
||||
if not isinstance(body, unicode_type):
|
||||
body = body.decode('utf-8')
|
||||
if isosx and not self.systray.isVisible():
|
||||
if ismacos and not self.systray.isVisible():
|
||||
self.systray.show()
|
||||
hide = True
|
||||
self.systray.showMessage(summary, body, self.systray.Information,
|
||||
@ -161,7 +161,7 @@ def get_notifier(systray=None):
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
ans = None
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
if get_osx_version() >= (10, 8, 0):
|
||||
ans = AppleNotifier()
|
||||
if not ans.ok:
|
||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (
|
||||
QBuffer, QPixmap, QAction, QKeySequence)
|
||||
|
||||
from calibre import as_unicode
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre.gui2 import error_dialog, choose_files, choose_images, elided_text, sanitize_env_vars, Application, choose_osx_app
|
||||
from calibre.gui2.widgets2 import Dialog
|
||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||
@ -146,7 +146,7 @@ if iswindows:
|
||||
det_msg='Command line: %r\n%s' %(cmdline, as_unicode(err)))
|
||||
# }}}
|
||||
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
# macOS {{{
|
||||
oprefs = JSONConfig('osx_open_with')
|
||||
from calibre.utils.open_with.osx import find_programs, get_icon, entry_to_cmdline, get_bundle_data
|
||||
|
@ -20,7 +20,7 @@ from PyQt5.Qt import (
|
||||
|
||||
from calibre import human_readable
|
||||
from calibre.ebooks.metadata.book.render import DEFAULT_AUTHOR_LINK
|
||||
from calibre.constants import isosx, iswindows
|
||||
from calibre.constants import ismacos, iswindows
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
from calibre.gui2 import default_author_link
|
||||
from calibre.gui2.dialogs.template_dialog import TemplateDialog
|
||||
@ -383,7 +383,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
def genesis(self, gui):
|
||||
self.gui = gui
|
||||
if not isosx and not iswindows:
|
||||
if not ismacos and not iswindows:
|
||||
self.label_widget_style.setVisible(False)
|
||||
self.opt_ui_style.setVisible(False)
|
||||
|
||||
@ -402,7 +402,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.default_author_link.changed_signal.connect(self.changed_signal)
|
||||
r('gui_layout', config, restart_required=True, choices=[(_('Wide'), 'wide'), (_('Narrow'), 'narrow')])
|
||||
r('hidpi', gprefs, restart_required=True, choices=[(_('Automatic'), 'auto'), (_('On'), 'on'), (_('Off'), 'off')])
|
||||
if isosx:
|
||||
if ismacos:
|
||||
self.opt_hidpi.setVisible(False), self.label_hidpi.setVisible(False)
|
||||
r('ui_style', gprefs, restart_required=True, choices=[(_('System default'), 'system'), (_('calibre style'), 'calibre')])
|
||||
r('book_list_tooltips', gprefs)
|
||||
|
@ -15,7 +15,7 @@ from PyQt5.Qt import (
|
||||
QToolButton, QIcon, QHBoxLayout, QPushButton, QListWidget, QListWidgetItem,
|
||||
QGridLayout, QPlainTextEdit, QLabel, QFrame, QDialog, QDialogButtonBox)
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.gui2.tweak_book.editor import all_text_syntaxes
|
||||
from calibre.gui2.tweak_book.editor.smarts.utils import get_text_before_cursor
|
||||
@ -27,7 +27,7 @@ from polyglot.builtins import codepoint_to_chr, iteritems, itervalues, unicode_t
|
||||
|
||||
string_length = lambda x: strlen(unicode_type(x)) # Needed on narrow python builds, as subclasses of unicode dont work
|
||||
KEY = Qt.Key_J
|
||||
MODIFIER = Qt.META if isosx else Qt.CTRL
|
||||
MODIFIER = Qt.META if ismacos else Qt.CTRL
|
||||
|
||||
SnipKey = namedtuple('SnipKey', 'trigger syntaxes')
|
||||
|
||||
|
@ -16,7 +16,7 @@ from PyQt5.Qt import (
|
||||
QMenu, QHBoxLayout, QTimer, QUrl, QSize)
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import __appname__, get_version, isosx, DEBUG
|
||||
from calibre.constants import __appname__, get_version, ismacos, DEBUG
|
||||
from calibre.customize.ui import find_plugin
|
||||
from calibre.gui2 import elided_text, open_url
|
||||
from calibre.gui2.dbus_export.widgets import factory
|
||||
@ -357,9 +357,9 @@ class Main(MainWindow):
|
||||
'edit-previous-file', 'Ctrl+Alt+Up', _('Edit the previous file in the spine'))
|
||||
# Qt does not generate shortcut overrides for cmd+arrow on os x which
|
||||
# means these shortcuts interfere with editing
|
||||
self.action_global_undo = treg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if isosx else 'Ctrl+Left',
|
||||
self.action_global_undo = treg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', () if ismacos else 'Ctrl+Left',
|
||||
_('Revert book to before the last action (Undo)'))
|
||||
self.action_global_redo = treg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', () if isosx else 'Ctrl+Right',
|
||||
self.action_global_redo = treg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', () if ismacos else 'Ctrl+Right',
|
||||
_('Revert book state to after the next action (Redo)'))
|
||||
self.action_save = treg('save.png', _('&Save'), self.boss.save_book, 'save-book', 'Ctrl+S', _('Save book'))
|
||||
self.action_save.setEnabled(False)
|
||||
@ -531,7 +531,7 @@ class Main(MainWindow):
|
||||
create_plugin_actions(actions, toolbar_actions, self.plugin_menu_actions)
|
||||
|
||||
def create_menubar(self):
|
||||
if isosx:
|
||||
if ismacos:
|
||||
p, q = self.create_application_menubar()
|
||||
q.triggered.connect(self.action_quit.trigger)
|
||||
p.triggered.connect(self.action_preferences.trigger)
|
||||
|
@ -21,7 +21,7 @@ from PyQt5.Qt import (
|
||||
|
||||
from calibre import prints, force_unicode, detect_ncpus
|
||||
from calibre.constants import (
|
||||
__appname__, isosx, iswindows, filesystem_encoding, DEBUG, config_dir)
|
||||
__appname__, ismacos, iswindows, filesystem_encoding, DEBUG, config_dir)
|
||||
from calibre.utils.config import prefs, dynamic
|
||||
from calibre.utils.ipc.pool import Pool
|
||||
from calibre.db.legacy import LibraryDatabase
|
||||
@ -271,7 +271,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
self.system_tray_icon = factory(app_id='com.calibre-ebook.gui').create_system_tray_icon(parent=self, title='calibre')
|
||||
if self.system_tray_icon is not None:
|
||||
self.system_tray_icon.setIcon(QIcon(I('lt.png', allow_user_override=False)))
|
||||
if not (iswindows or isosx):
|
||||
if not (iswindows or ismacos):
|
||||
self.system_tray_icon.setIcon(QIcon.fromTheme('calibre-tray', self.system_tray_icon.icon()))
|
||||
self.system_tray_icon.setToolTip(self.jobs_button.tray_tooltip())
|
||||
self.system_tray_icon.setVisible(True)
|
||||
@ -1069,7 +1069,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
return
|
||||
self.write_settings()
|
||||
if self.system_tray_icon is not None and self.system_tray_icon.isVisible():
|
||||
if not dynamic['systray_msg'] and not isosx:
|
||||
if not dynamic['systray_msg'] and not ismacos:
|
||||
info_dialog(self, 'calibre', 'calibre '+
|
||||
_('will keep running in the system tray. To close it, '
|
||||
'choose <b>Quit</b> in the context menu of the '
|
||||
|
@ -9,7 +9,7 @@ from threading import Thread, Event
|
||||
from PyQt5.Qt import (QObject, pyqtSignal, Qt, QUrl, QDialog, QGridLayout,
|
||||
QLabel, QCheckBox, QDialogButtonBox, QIcon)
|
||||
|
||||
from calibre.constants import (__appname__, __version__, iswindows, isosx,
|
||||
from calibre.constants import (__appname__, __version__, iswindows, ismacos,
|
||||
isportable, is64bit, numeric_version)
|
||||
from calibre import prints, as_unicode
|
||||
from calibre.utils.config import prefs
|
||||
@ -28,7 +28,7 @@ NO_CALIBRE_UPDATE = (0, 0, 0)
|
||||
|
||||
def get_download_url():
|
||||
which = ('portable' if isportable else 'windows' if iswindows
|
||||
else 'osx' if isosx else 'linux')
|
||||
else 'osx' if ismacos else 'linux')
|
||||
if which == 'windows' and is64bit:
|
||||
which += '64'
|
||||
return localize_website_link('https://calibre-ebook.com/download_' + which)
|
||||
@ -41,7 +41,7 @@ def get_newest_version():
|
||||
icon_theme_name = ''
|
||||
headers={
|
||||
'CALIBRE-VERSION':__version__,
|
||||
'CALIBRE-OS': ('win' if iswindows else 'osx' if isosx else 'oth'),
|
||||
'CALIBRE-OS': ('win' if iswindows else 'osx' if ismacos else 'oth'),
|
||||
'CALIBRE-INSTALL-UUID': prefs['installation_uuid'],
|
||||
'CALIBRE-ICON-THEME': icon_theme_name,
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ from PyQt5.Qt import (
|
||||
)
|
||||
from PyQt5.QtWebEngineWidgets import QWebEnginePage
|
||||
|
||||
from calibre.constants import isosx
|
||||
from calibre.constants import ismacos
|
||||
from calibre.gui2 import elided_text
|
||||
from calibre.gui2.viewer.config import get_session_pref
|
||||
from calibre.gui2.viewer.shortcuts import index_to_key_sequence
|
||||
@ -313,7 +313,7 @@ class ActionsList(QListWidget):
|
||||
self.viewport().setAcceptDrops(True)
|
||||
self.setDropIndicatorShown(True)
|
||||
self.setDragDropMode(self.InternalMove)
|
||||
self.setDefaultDropAction(Qt.CopyAction if isosx else Qt.MoveAction)
|
||||
self.setDefaultDropAction(Qt.CopyAction if ismacos else Qt.MoveAction)
|
||||
self.setMinimumHeight(400)
|
||||
self.is_source = is_source
|
||||
if is_source:
|
||||
|
@ -20,7 +20,7 @@ from PyQt5.QtWebEngineWidgets import (
|
||||
from calibre import as_unicode, prints
|
||||
from calibre.constants import (
|
||||
FAKE_HOST, FAKE_PROTOCOL, __version__, in_develop_mode, is_running_from_develop,
|
||||
isosx, iswindows
|
||||
ismacos, iswindows
|
||||
)
|
||||
from calibre.ebooks.metadata.book.base import field_metadata
|
||||
from calibre.ebooks.oeb.polish.utils import guess_type
|
||||
@ -204,7 +204,7 @@ def create_profile():
|
||||
ans = getattr(create_profile, 'ans', None)
|
||||
if ans is None:
|
||||
ans = QWebEngineProfile(QApplication.instance())
|
||||
osname = 'windows' if iswindows else ('macos' if isosx else 'linux')
|
||||
osname = 'windows' if iswindows else ('macos' if ismacos else 'linux')
|
||||
# DO NOT change the user agent as it is used to workaround
|
||||
# Qt bugs see workaround_qt_bug() in ajax.pyj
|
||||
ua = 'calibre-viewer {} {}'.format(__version__, osname)
|
||||
|
@ -14,7 +14,7 @@ from PyQt5.Qt import (QIcon, QFont, QLabel, QListWidget, QAction,
|
||||
QLineEdit, QComboBox, QPen, QGraphicsScene, QMenu, QStringListModel,
|
||||
QCompleter, QTimer, QRect, QGraphicsView, QPagedPaintDevice)
|
||||
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre.gui2 import (error_dialog, pixmap_to_data, gprefs,
|
||||
warning_dialog)
|
||||
from calibre.gui2.filename_pattern_ui import Ui_Form
|
||||
@ -1249,7 +1249,7 @@ class PaperSizes(QComboBox): # {{{
|
||||
from calibre.utils.icu import numeric_sort_key
|
||||
if self.system_default_paper_size is None:
|
||||
PaperSizes.system_default_paper_size = 'a4'
|
||||
if iswindows or isosx:
|
||||
if iswindows or ismacos:
|
||||
# On Linux, this can cause Qt to load the system cups plugin
|
||||
# which can crash: https://bugs.launchpad.net/calibre/+bug/1861741
|
||||
PaperSizes.system_default_paper_size = 'letter' if QPrinter().pageSize() == QPagedPaintDevice.Letter else 'a4'
|
||||
|
@ -20,7 +20,7 @@ from calibre import (
|
||||
as_unicode, force_unicode, isbytestring, prepare_string_for_xml,
|
||||
replace_entities, strftime, xml_replace_entities
|
||||
)
|
||||
from calibre.constants import cache_dir, isosx
|
||||
from calibre.constants import cache_dir, ismacos
|
||||
from calibre.utils.xml_parse import safe_xml_fromstring
|
||||
from calibre.customize.conversion import DummyReporter
|
||||
from calibre.customize.ui import output_profiles
|
||||
@ -706,7 +706,7 @@ class CatalogBuilder(object):
|
||||
c = item
|
||||
|
||||
ordnum, ordlen = collation_order(c)
|
||||
if isosx and platform.mac_ver()[0] < '10.8':
|
||||
if ismacos and platform.mac_ver()[0] < '10.8':
|
||||
# Hackhackhackhackhack
|
||||
# icu returns bogus results with curly apostrophes, maybe others under OS X 10.6.x
|
||||
# When we see the magic combo of 0/-1 for ordnum/ordlen, special case the logic
|
||||
|
@ -9,7 +9,7 @@ import tempfile, os, atexit
|
||||
from polyglot.builtins import map, getenv
|
||||
|
||||
from calibre.constants import (__version__, __appname__, filesystem_encoding,
|
||||
iswindows, get_windows_temp_path, isosx)
|
||||
iswindows, get_windows_temp_path, ismacos)
|
||||
|
||||
|
||||
def cleanup(path):
|
||||
@ -113,7 +113,7 @@ def base_dir():
|
||||
# unicode temp path instead. See
|
||||
# https://bugs.launchpad.net/bugs/937389
|
||||
base = get_windows_temp_path()
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
# Use the cache dir rather than the temp dir for temp files as Apple
|
||||
# thinks deleting unused temp files is a good idea. See note under
|
||||
# _CS_DARWIN_USER_TEMP_DIR here
|
||||
|
@ -8,7 +8,7 @@ __copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
import os, sys, subprocess, signal, time, errno, socket, ssl
|
||||
from threading import Thread, Lock
|
||||
|
||||
from calibre.constants import islinux, iswindows, isosx
|
||||
from calibre.constants import islinux, iswindows, ismacos
|
||||
from calibre.srv.http_response import create_http_handler
|
||||
from calibre.srv.loop import ServerLoop
|
||||
from calibre.srv.opts import Options
|
||||
@ -161,7 +161,7 @@ elif iswindows:
|
||||
else:
|
||||
self.handle_modified({path})
|
||||
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
from fsevents import Observer, Stream
|
||||
|
||||
class Watcher(WatcherBase):
|
||||
|
@ -9,7 +9,7 @@ import os, ctypes, errno, socket
|
||||
from io import DEFAULT_BUFFER_SIZE
|
||||
from select import select
|
||||
|
||||
from calibre.constants import islinux, isosx
|
||||
from calibre.constants import islinux, ismacos
|
||||
from calibre.srv.utils import eintr_retry_call
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ class SendfileInterrupted(Exception):
|
||||
|
||||
sendfile_to_socket = sendfile_to_socket_async = None
|
||||
|
||||
if isosx:
|
||||
if ismacos:
|
||||
libc = ctypes.CDLL(None, use_errno=True)
|
||||
sendfile = ctypes.CFUNCTYPE(
|
||||
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int64, ctypes.POINTER(ctypes.c_int64), ctypes.c_void_p, ctypes.c_int, use_errno=True)(
|
||||
|
@ -9,7 +9,7 @@ import signal
|
||||
import sys
|
||||
|
||||
from calibre import as_unicode
|
||||
from calibre.constants import is_running_from_develop, isosx, iswindows, plugins
|
||||
from calibre.constants import is_running_from_develop, ismacos, iswindows, plugins
|
||||
from calibre.db.delete_service import shutdown as shutdown_delete_service
|
||||
from calibre.db.legacy import LibraryDatabase
|
||||
from calibre.srv.bonjour import BonJour
|
||||
@ -129,7 +129,7 @@ libraries that the main calibre program knows about will be used.
|
||||
' URLs and export them.'
|
||||
))
|
||||
|
||||
if not iswindows and not isosx:
|
||||
if not iswindows and not ismacos:
|
||||
# Does not work on macOS because if we fork() we cannot connect to Core
|
||||
# Serives which is needed by the QApplication() constructor, which in
|
||||
# turn is needed by ensure_app()
|
||||
|
@ -21,7 +21,7 @@ builtins.__dict__['__'] = lambda s: s
|
||||
builtins.__dict__['dynamic_property'] = lambda func: func(None)
|
||||
|
||||
|
||||
from calibre.constants import iswindows, preferred_encoding, plugins, isosx, islinux, DEBUG, isfreebsd
|
||||
from calibre.constants import iswindows, preferred_encoding, plugins, ismacos, islinux, DEBUG, isfreebsd
|
||||
|
||||
_run_once = False
|
||||
winutil = winutilerror = None
|
||||
@ -100,7 +100,7 @@ if not _run_once:
|
||||
#
|
||||
# Convert command line arguments to unicode
|
||||
enc = preferred_encoding
|
||||
if isosx:
|
||||
if ismacos:
|
||||
enc = 'utf-8'
|
||||
for i in range(1, len(sys.argv)):
|
||||
if not isinstance(sys.argv[i], unicode_type):
|
||||
@ -199,7 +199,7 @@ if not _run_once:
|
||||
bound_signal.connect(slot, **kw)
|
||||
builtins.__dict__['connect_lambda'] = connect_lambda
|
||||
|
||||
if islinux or isosx or isfreebsd:
|
||||
if islinux or ismacos or isfreebsd:
|
||||
# Name all threads at the OS level created using the threading module, see
|
||||
# http://bugs.python.org/issue15500
|
||||
import threading
|
||||
|
@ -12,7 +12,7 @@ Test a binary calibre build to ensure that all needed binary images/libraries ha
|
||||
|
||||
import os, ctypes, sys, unittest, time
|
||||
|
||||
from calibre.constants import plugins, iswindows, islinux, isosx, plugins_loc
|
||||
from calibre.constants import plugins, iswindows, islinux, ismacos, plugins_loc
|
||||
from polyglot.builtins import iteritems, map, unicode_type, getenv, native_string_type
|
||||
|
||||
is_ci = os.environ.get('CI', '').lower() == 'true'
|
||||
@ -100,7 +100,7 @@ class BuildTest(unittest.TestCase):
|
||||
if name in exclusions:
|
||||
if name in ('libusb', 'libmtp'):
|
||||
# Just check that the DLL can be loaded
|
||||
ctypes.CDLL(os.path.join(plugins_loc, name + ('.dylib' if isosx else '.so')))
|
||||
ctypes.CDLL(os.path.join(plugins_loc, name + ('.dylib' if ismacos else '.so')))
|
||||
continue
|
||||
mod, err = plugins[name]
|
||||
self.assertFalse(err or not mod, 'Failed to load plugin: ' + name + ' with error:\n' + err)
|
||||
@ -128,7 +128,7 @@ class BuildTest(unittest.TestCase):
|
||||
large = b'x' * (100 * 1024 * 1024)
|
||||
msgpack_loads(msgpack_dumps(large))
|
||||
|
||||
@unittest.skipUnless(isosx, 'FSEvents only present on OS X')
|
||||
@unittest.skipUnless(ismacos, 'FSEvents only present on OS X')
|
||||
def test_fsevents(self):
|
||||
from fsevents import Observer, Stream
|
||||
del Observer, Stream
|
||||
@ -235,7 +235,7 @@ class BuildTest(unittest.TestCase):
|
||||
p.printToPdf(print_callback)
|
||||
QTimer.singleShot(5000, lambda: QApplication.instance().quit())
|
||||
QApplication.instance().exec_()
|
||||
test_flaky = isosx and not is_ci
|
||||
test_flaky = ismacos and not is_ci
|
||||
if not test_flaky:
|
||||
self.assertEqual(callback.result, 2, 'Simple JS computation failed')
|
||||
self.assertIn(b'Skia/PDF', bytes(print_callback.result), 'Print to PDF failed')
|
||||
@ -334,7 +334,7 @@ class BuildTest(unittest.TestCase):
|
||||
def test_openssl(self):
|
||||
import ssl
|
||||
ssl.PROTOCOL_TLSv1_2
|
||||
if isosx:
|
||||
if ismacos:
|
||||
cafile = ssl.get_default_verify_paths().cafile
|
||||
if not cafile or not cafile.endswith('/mozilla-ca-certs.pem') or not os.access(cafile, os.R_OK):
|
||||
raise AssertionError('Mozilla CA certs not loaded')
|
||||
|
@ -11,7 +11,7 @@ from datetime import datetime, time as dtime, timedelta, MINYEAR, MAXYEAR
|
||||
from functools import partial
|
||||
|
||||
from calibre import strftime
|
||||
from calibre.constants import iswindows, isosx, plugins, preferred_encoding
|
||||
from calibre.constants import iswindows, ismacos, plugins, preferred_encoding
|
||||
from calibre.utils.iso8601 import utc_tz, local_tz, UNDEFINED_DATE
|
||||
from calibre.utils.localization import lcdata
|
||||
from polyglot.builtins import unicode_type, native_string_type
|
||||
@ -31,7 +31,7 @@ if iswindows:
|
||||
except:
|
||||
parse_date_day_first = False
|
||||
del ctypes, LOCALE_SSHORTDATE, buf, LOCALE_USER_DEFAULT
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
try:
|
||||
date_fmt = plugins['usbobserver'][0].date_format()
|
||||
parse_date_day_first = date_fmt.index('d') < date_fmt.index('M')
|
||||
|
@ -12,7 +12,7 @@ from math import ceil
|
||||
|
||||
from calibre import force_unicode, isbytestring, prints, sanitize_file_name
|
||||
from calibre.constants import (
|
||||
filesystem_encoding, iswindows, plugins, preferred_encoding, isosx
|
||||
filesystem_encoding, iswindows, plugins, preferred_encoding, ismacos
|
||||
)
|
||||
from calibre.utils.localization import get_udc
|
||||
from polyglot.builtins import iteritems, itervalues, unicode_type, range
|
||||
@ -52,7 +52,7 @@ def shorten_component(s, by_what):
|
||||
def limit_component(x, limit=254):
|
||||
# windows and macs use ytf-16 codepoints for length, linux uses arbitrary
|
||||
# binary data, but we will assume utf-8
|
||||
filename_encoding_for_length = 'utf-16' if iswindows or isosx else 'utf-8'
|
||||
filename_encoding_for_length = 'utf-16' if iswindows or ismacos else 'utf-8'
|
||||
|
||||
def encoded_length():
|
||||
q = x if isinstance(x, bytes) else x.encode(filename_encoding_for_length)
|
||||
|
@ -11,7 +11,7 @@ from collections import defaultdict
|
||||
from threading import Thread
|
||||
|
||||
from calibre import walk, prints, as_unicode
|
||||
from calibre.constants import (config_dir, iswindows, isosx, plugins, DEBUG,
|
||||
from calibre.constants import (config_dir, iswindows, ismacos, plugins, DEBUG,
|
||||
isworker, filesystem_encoding)
|
||||
from calibre.utils.fonts.metadata import FontMetadata, UnsupportedFont
|
||||
from calibre.utils.icu import sort_key
|
||||
@ -113,7 +113,7 @@ def font_dirs():
|
||||
path = os.path.join(path, r'Microsoft\Windows\Fonts')
|
||||
paths.add(os.path.normcase(path))
|
||||
return list(paths)
|
||||
if isosx:
|
||||
if ismacos:
|
||||
return [
|
||||
'/Library/Fonts',
|
||||
'/System/Library/Fonts',
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
import subprocess, re
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
|
||||
|
||||
def get_address_of_default_gateway(family='AF_INET'):
|
||||
@ -56,7 +56,7 @@ if iswindows:
|
||||
get_default_route_src_address = get_default_route_src_address_api
|
||||
|
||||
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
|
||||
def get_default_route_src_address():
|
||||
# Use -inet6 for IPv6
|
||||
|
@ -7,7 +7,7 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import subprocess, os, sys, time
|
||||
|
||||
from calibre.constants import iswindows, isosx, isfrozen
|
||||
from calibre.constants import iswindows, ismacos, isfrozen
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.ptempfile import PersistentTemporaryFile, base_dir
|
||||
from calibre.utils.serialize import msgpack_dumps
|
||||
@ -56,7 +56,7 @@ class Worker(object):
|
||||
if iswindows:
|
||||
return os.path.join(os.path.dirname(sys.executable),
|
||||
e+'.exe' if isfrozen else 'Scripts\\%s.exe'%e)
|
||||
if isosx:
|
||||
if ismacos:
|
||||
return os.path.join(sys.executables_location, e)
|
||||
|
||||
if isfrozen:
|
||||
@ -70,7 +70,7 @@ class Worker(object):
|
||||
|
||||
@property
|
||||
def gui_executable(self):
|
||||
if isosx and not hasattr(sys, 'running_from_setup'):
|
||||
if ismacos and not hasattr(sys, 'running_from_setup'):
|
||||
if self.job_name == 'ebook-viewer':
|
||||
base = os.path.dirname(sys.executables_location)
|
||||
return os.path.join(base, 'ebook-viewer.app/Contents/MacOS/', self.exe_name)
|
||||
|
@ -13,7 +13,7 @@ from contextlib import closing
|
||||
from zipimport import ZipImportError
|
||||
|
||||
from calibre import prints
|
||||
from calibre.constants import iswindows, isosx
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre.utils.ipc import eintr_retry_call
|
||||
from calibre.utils.serialize import msgpack_loads, pickle_dumps
|
||||
from polyglot.queue import Queue
|
||||
@ -171,7 +171,7 @@ def main():
|
||||
# Close open file descriptors inherited from parent
|
||||
# On Unix this is done by the subprocess module
|
||||
os.closerange(3, 256)
|
||||
if isosx and 'CALIBRE_WORKER_ADDRESS' not in os.environ and 'CALIBRE_SIMPLE_WORKER' not in os.environ and '--pipe-worker' not in sys.argv:
|
||||
if ismacos and 'CALIBRE_WORKER_ADDRESS' not in os.environ and 'CALIBRE_SIMPLE_WORKER' not in os.environ and '--pipe-worker' not in sys.argv:
|
||||
# On some OS X computers launchd apparently tries to
|
||||
# launch the last run process from the bundle
|
||||
# so launch the gui as usual
|
||||
|
@ -29,7 +29,7 @@ def available_translations():
|
||||
|
||||
|
||||
def get_system_locale():
|
||||
from calibre.constants import iswindows, isosx, plugins
|
||||
from calibre.constants import iswindows, ismacos, plugins
|
||||
lang = None
|
||||
if iswindows:
|
||||
try:
|
||||
@ -40,7 +40,7 @@ def get_system_locale():
|
||||
lang = None
|
||||
except:
|
||||
pass # Windows XP does not have the GetUserDefaultLocaleName fn
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
try:
|
||||
lang = plugins['usbobserver'][0].user_locale() or None
|
||||
except:
|
||||
|
@ -11,7 +11,7 @@ import time
|
||||
from functools import partial
|
||||
|
||||
from calibre.constants import (
|
||||
__appname__, fcntl, filesystem_encoding, islinux, isosx, iswindows, plugins
|
||||
__appname__, fcntl, filesystem_encoding, islinux, ismacos, iswindows, plugins
|
||||
)
|
||||
from calibre.utils.monotonic import monotonic
|
||||
from calibre.utils.shared_file import raise_winerror
|
||||
@ -172,7 +172,7 @@ else:
|
||||
)
|
||||
home = os.path.expanduser('~')
|
||||
locs = ['/var/lock', home, tempfile.gettempdir()]
|
||||
if isosx:
|
||||
if ismacos:
|
||||
locs.insert(0, '/Library/Caches')
|
||||
for loc in locs:
|
||||
if os.access(loc, os.W_OK | os.R_OK | os.X_OK):
|
||||
|
@ -9,7 +9,7 @@ __docformat__ = 'restructuredtext en'
|
||||
import os, shutil, time, sys
|
||||
|
||||
from calibre import isbytestring
|
||||
from calibre.constants import (iswindows, isosx, plugins, filesystem_encoding,
|
||||
from calibre.constants import (iswindows, ismacos, plugins, filesystem_encoding,
|
||||
islinux)
|
||||
from polyglot.builtins import unicode_type
|
||||
|
||||
@ -85,7 +85,7 @@ if iswindows:
|
||||
path = os.path.abspath(path) # Windows does not like recycling relative paths
|
||||
return delegate_recycle(path)
|
||||
|
||||
elif isosx:
|
||||
elif ismacos:
|
||||
u = plugins['cocoa'][0]
|
||||
if hasattr(u, 'send2trash'):
|
||||
def osx_recycle(path):
|
||||
|
Loading…
x
Reference in New Issue
Block a user