mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: more future imports
This commit is contained in:
parent
b71bd6478b
commit
92e5dcb078
@ -1,37 +1,35 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||||
from __future__ import with_statement
|
# License: GPLv3 Copyright: 2009, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from PyQt5.Qt import (
|
from PyQt5.Qt import (
|
||||||
QAbstractListModel, Qt, QFont, QModelIndex, QDialog, QCoreApplication,
|
QAbstractListModel, QCheckBox, QComboBox, QCoreApplication, QDialog,
|
||||||
QSize, QDialogButtonBox, QGridLayout, QHBoxLayout, QCheckBox, QLabel,
|
QDialogButtonBox, QFont, QFrame, QGridLayout, QHBoxLayout, QIcon, QLabel,
|
||||||
QIcon, QComboBox, QListView, QSizePolicy, QSpacerItem, QStackedWidget,
|
QListView, QModelIndex, QRect, QScrollArea, QSize, QSizePolicy, QSpacerItem,
|
||||||
QVBoxLayout, QFrame, QWidget, QTextEdit, QScrollArea, QRect)
|
QStackedWidget, Qt, QTextEdit, QVBoxLayout, QWidget
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.customize.conversion import OptionRecommendation
|
||||||
from calibre.ebooks.conversion.config import (
|
from calibre.ebooks.conversion.config import (
|
||||||
GuiRecommendations, save_specifics, sort_formats_by_preference, get_input_format_for_book, get_output_formats)
|
GuiRecommendations, delete_specifics, get_input_format_for_book,
|
||||||
from calibre.gui2.convert.metadata import MetadataWidget
|
get_output_formats, save_specifics, sort_formats_by_preference
|
||||||
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
)
|
||||||
|
from calibre.ebooks.conversion.plumber import create_dummy_plumber
|
||||||
|
from calibre.gui2 import gprefs
|
||||||
|
from calibre.gui2.convert.debug import DebugWidget
|
||||||
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
from calibre.gui2.convert.heuristics import HeuristicsWidget
|
||||||
from calibre.gui2.convert.search_and_replace import SearchAndReplaceWidget
|
from calibre.gui2.convert.look_and_feel import LookAndFeelWidget
|
||||||
|
from calibre.gui2.convert.metadata import MetadataWidget
|
||||||
from calibre.gui2.convert.page_setup import PageSetupWidget
|
from calibre.gui2.convert.page_setup import PageSetupWidget
|
||||||
|
from calibre.gui2.convert.search_and_replace import SearchAndReplaceWidget
|
||||||
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
from calibre.gui2.convert.structure_detection import StructureDetectionWidget
|
||||||
from calibre.gui2.convert.toc import TOCWidget
|
from calibre.gui2.convert.toc import TOCWidget
|
||||||
from calibre.gui2.convert.debug import DebugWidget
|
|
||||||
|
|
||||||
|
|
||||||
from calibre.ebooks.conversion.plumber import create_dummy_plumber
|
|
||||||
from calibre.ebooks.conversion.config import delete_specifics
|
|
||||||
from calibre.customize.conversion import OptionRecommendation
|
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
from polyglot.builtins import unicode_type, range
|
from polyglot.builtins import native_string_type, range, unicode_type
|
||||||
|
|
||||||
|
|
||||||
class GroupModel(QAbstractListModel):
|
class GroupModel(QAbstractListModel):
|
||||||
@ -83,8 +81,8 @@ class Config(QDialog):
|
|||||||
preferred_output_format)
|
preferred_output_format)
|
||||||
self.setup_pipeline()
|
self.setup_pipeline()
|
||||||
|
|
||||||
self.input_formats.currentIndexChanged[str].connect(self.setup_pipeline)
|
self.input_formats.currentIndexChanged[native_string_type].connect(self.setup_pipeline)
|
||||||
self.output_formats.currentIndexChanged[str].connect(self.setup_pipeline)
|
self.output_formats.currentIndexChanged[native_string_type].connect(self.setup_pipeline)
|
||||||
self.groups.setSpacing(5)
|
self.groups.setSpacing(5)
|
||||||
self.groups.activated[(QModelIndex)].connect(self.show_pane)
|
self.groups.activated[(QModelIndex)].connect(self.show_pane)
|
||||||
self.groups.clicked[(QModelIndex)].connect(self.show_pane)
|
self.groups.clicked[(QModelIndex)].connect(self.show_pane)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPLv3 Copyright: 2015, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __future__ import print_function
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -28,7 +28,7 @@ from calibre.utils.config import dynamic, prefs
|
|||||||
from calibre.utils.ipc import RC, gui_socket_address
|
from calibre.utils.ipc import RC, gui_socket_address
|
||||||
from calibre.utils.lock import singleinstance
|
from calibre.utils.lock import singleinstance
|
||||||
from calibre.utils.monotonic import monotonic
|
from calibre.utils.monotonic import monotonic
|
||||||
from polyglot.builtins import unicode_type, range, environ_item
|
from polyglot.builtins import as_bytes, environ_item, range, unicode_type
|
||||||
|
|
||||||
if iswindows:
|
if iswindows:
|
||||||
winutil = plugins['winutil'][0]
|
winutil = plugins['winutil'][0]
|
||||||
@ -71,9 +71,9 @@ def find_portable_library():
|
|||||||
return
|
return
|
||||||
import glob
|
import glob
|
||||||
candidates = [os.path.basename(os.path.dirname(x)) for x in glob.glob(
|
candidates = [os.path.basename(os.path.dirname(x)) for x in glob.glob(
|
||||||
os.path.join(base, u'*%smetadata.db'%os.sep))]
|
os.path.join(base, '*%smetadata.db'%os.sep))]
|
||||||
if not candidates:
|
if not candidates:
|
||||||
candidates = [u'Calibre Library']
|
candidates = ['Calibre Library']
|
||||||
lp = prefs['library_path']
|
lp = prefs['library_path']
|
||||||
if not lp:
|
if not lp:
|
||||||
lib = os.path.join(base, candidates[0])
|
lib = os.path.join(base, candidates[0])
|
||||||
@ -134,13 +134,13 @@ def get_default_library_path():
|
|||||||
if isinstance(fname, unicode_type):
|
if isinstance(fname, unicode_type):
|
||||||
try:
|
try:
|
||||||
fname.encode(filesystem_encoding)
|
fname.encode(filesystem_encoding)
|
||||||
except:
|
except Exception:
|
||||||
fname = 'Calibre Library'
|
fname = 'Calibre Library'
|
||||||
x = os.path.expanduser('~'+os.sep+fname)
|
x = os.path.expanduser('~'+os.sep+fname)
|
||||||
if not os.path.exists(x):
|
if not os.path.exists(x):
|
||||||
try:
|
try:
|
||||||
os.makedirs(x)
|
os.makedirs(x)
|
||||||
except:
|
except Exception:
|
||||||
x = os.path.expanduser('~')
|
x = os.path.expanduser('~')
|
||||||
return x
|
return x
|
||||||
|
|
||||||
@ -360,8 +360,8 @@ def run_in_debug_mode():
|
|||||||
os.close(fd)
|
os.close(fd)
|
||||||
os.environ['CALIBRE_RESTARTING_FROM_GUI'] = environ_item('1')
|
os.environ['CALIBRE_RESTARTING_FROM_GUI'] = environ_item('1')
|
||||||
run_calibre_debug(
|
run_calibre_debug(
|
||||||
'--gui-debug', logpath, stdout=lopen(logpath, 'w'),
|
'--gui-debug', logpath, stdout=lopen(logpath, 'wb'),
|
||||||
stderr=subprocess.STDOUT, stdin=lopen(os.devnull, 'r'))
|
stderr=subprocess.STDOUT, stdin=lopen(os.devnull, 'rb'))
|
||||||
|
|
||||||
|
|
||||||
def shellquote(s):
|
def shellquote(s):
|
||||||
@ -478,7 +478,7 @@ def shutdown_other(rc=None):
|
|||||||
if rc.conn is None:
|
if rc.conn is None:
|
||||||
prints(_('No running calibre found'))
|
prints(_('No running calibre found'))
|
||||||
return # No running instance found
|
return # No running instance found
|
||||||
rc.conn.send('shutdown:')
|
rc.conn.send(b'shutdown:')
|
||||||
prints(_('Shutdown command sent, waiting for shutdown...'))
|
prints(_('Shutdown command sent, waiting for shutdown...'))
|
||||||
for i in range(50):
|
for i in range(50):
|
||||||
if singleinstance(singleinstance_name):
|
if singleinstance(singleinstance_name):
|
||||||
@ -496,7 +496,7 @@ def communicate(opts, args):
|
|||||||
if len(args) > 1:
|
if len(args) > 1:
|
||||||
args[1:] = [os.path.abspath(x) if os.path.exists(x) else x for x in args[1:]]
|
args[1:] = [os.path.abspath(x) if os.path.exists(x) else x for x in args[1:]]
|
||||||
import json
|
import json
|
||||||
t.conn.send('launched:'+json.dumps(args))
|
t.conn.send(b'launched:'+as_bytes(json.dumps(args)))
|
||||||
t.conn.close()
|
t.conn.close()
|
||||||
raise SystemExit(0)
|
raise SystemExit(0)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user