This commit is contained in:
Kovid Goyal 2019-09-12 20:37:42 +05:30
commit 81f9a0d50d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
13 changed files with 41 additions and 37 deletions

View File

@ -11,6 +11,7 @@
# General Public License for more details. # General Public License for more details.
# $Id: __init__.py,v 1.8 2006/06/18 10:50:43 rubensr Exp $ # $Id: __init__.py,v 1.8 2006/06/18 10:50:43 rubensr Exp $
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
chm - A package to manipulate CHM files chm - A package to manipulate CHM files
@ -23,6 +24,7 @@
the chm module provides some higher level classes to simplify the chm module provides some higher level classes to simplify
access to the CHM files information. access to the CHM files information.
''' '''
__all__ = ["chm", "chmlib", "_chmlib", "extra"] __all__ = ["chm", "chmlib", "_chmlib", "extra"]
__version__ = "0.8.4" __version__ = "0.8.4"
__revision__ = "$Id: __init__.py,v 1.8 2006/06/18 10:50:43 rubensr Exp $" __revision__ = "$Id: __init__.py,v 1.8 2006/06/18 10:50:43 rubensr Exp $"

View File

@ -14,6 +14,7 @@
# General Public License for more details. # General Public License for more details.
# $Id: chm.py,v 1.12 2006/08/07 12:31:51 rubensr Exp $ # $Id: chm.py,v 1.12 2006/08/07 12:31:51 rubensr Exp $
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
chm - A high-level front end for the chmlib python module. chm - A high-level front end for the chmlib python module.

View File

@ -1,6 +1,6 @@
#!/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, print_function from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
@ -41,11 +41,7 @@ else:
raise raise
arg = repr(arg) arg = repr(arg)
if not isinstance(arg, bytes): if not isinstance(arg, bytes):
try:
arg = str(arg)
except ValueError:
arg = unicode_type(arg) arg = unicode_type(arg)
if isinstance(arg, unicode_type):
try: try:
arg = arg.encode(enc) arg = arg.encode(enc)
except UnicodeEncodeError: except UnicodeEncodeError:

View File

@ -1,8 +1,7 @@
#!/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 from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'

View File

@ -1,6 +1,6 @@
#!/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 from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,6 +1,6 @@
#!/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 from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
@ -179,7 +179,7 @@ class Worker(object):
origwd = cwd or os.path.abspath(getcwd()) origwd = cwd or os.path.abspath(getcwd())
except EnvironmentError: except EnvironmentError:
# cwd no longer exists # cwd no longer exists
origwd = cwd or os.path.expanduser(u'~') origwd = cwd or os.path.expanduser('~')
env[native_string_type('ORIGWD')] = environ_item(as_hex_unicode(msgpack_dumps(origwd))) env[native_string_type('ORIGWD')] = environ_item(as_hex_unicode(msgpack_dumps(origwd)))
_cwd = cwd _cwd = cwd
if priority is None: if priority is None:

View File

@ -1,6 +1,6 @@
#!/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 print_function, with_statement from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
@ -134,7 +134,7 @@ if islinux:
def create_listener(authkey, backlog=4): def create_listener(authkey, backlog=4):
# Use abstract named sockets on linux to avoid creating unnecessary temp files # Use abstract named sockets on linux to avoid creating unnecessary temp files
prefix = u'\0calibre-ipc-listener-%d-%%d' % os.getpid() prefix = '\0calibre-ipc-listener-%d-%%d' % os.getpid()
while True: while True:
address = (prefix % next(_name_counter)) address = (prefix % next(_name_counter))
if not ispy3 and not isinstance(address, bytes): if not ispy3 and not isinstance(address, bytes):
@ -214,8 +214,8 @@ class Server(Thread):
with self._worker_launch_lock: with self._worker_launch_lock:
self.launched_worker_count += 1 self.launched_worker_count += 1
id = self.launched_worker_count id = self.launched_worker_count
fd, rfile = tempfile.mkstemp(prefix=u'ipc_result_%d_%d_'%(self.id, id), fd, rfile = tempfile.mkstemp(prefix='ipc_result_%d_%d_'%(self.id, id),
dir=base_dir(), suffix=u'.pickle') dir=base_dir(), suffix='.pickle')
os.close(fd) os.close(fd)
if redirect_output is None: if redirect_output is None:
redirect_output = not gui redirect_output = not gui

View File

@ -1,7 +1,6 @@
#!/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 from __future__ import absolute_import, division, print_function, unicode_literals
from __future__ import print_function
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,6 +1,6 @@
#!/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 absolute_import, print_function from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
@ -20,7 +20,8 @@ def available_translations():
stats = P('localization/stats.calibre_msgpack', allow_user_override=False) stats = P('localization/stats.calibre_msgpack', allow_user_override=False)
if os.path.exists(stats): if os.path.exists(stats):
from calibre.utils.serialize import msgpack_loads from calibre.utils.serialize import msgpack_loads
stats = msgpack_loads(open(stats, 'rb').read()) with open(stats, 'rb') as f:
stats = msgpack_loads(f.read())
else: else:
stats = {} stats = {}
_available_translations = [x for x in stats if stats[x] > 0.1] _available_translations = [x for x in stats if stats[x] > 0.1]
@ -180,18 +181,18 @@ def get_translator(bcp_47_code):
lcdata = { lcdata = {
u'abday': (u'Sun', u'Mon', u'Tue', u'Wed', u'Thu', u'Fri', u'Sat'), 'abday': ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
u'abmon': (u'Jan', u'Feb', u'Mar', u'Apr', u'May', u'Jun', u'Jul', u'Aug', u'Sep', u'Oct', u'Nov', u'Dec'), 'abmon': ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
u'd_fmt': u'%m/%d/%Y', 'd_fmt': '%m/%d/%Y',
u'd_t_fmt': u'%a %d %b %Y %r %Z', 'd_t_fmt': '%a %d %b %Y %r %Z',
u'day': (u'Sunday', u'Monday', u'Tuesday', u'Wednesday', u'Thursday', u'Friday', u'Saturday'), 'day': ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
u'mon': (u'January', u'February', u'March', u'April', u'May', u'June', u'July', u'August', u'September', u'October', u'November', u'December'), 'mon': ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
u'noexpr': u'^[nN].*', 'noexpr': '^[nN].*',
u'radixchar': u'.', 'radixchar': '.',
u't_fmt': u'%r', 't_fmt': '%r',
u't_fmt_ampm': u'%I:%M:%S %p', 't_fmt_ampm': '%I:%M:%S %p',
u'thousep': u',', 'thousep': ',',
u'yesexpr': u'^[yY].*' 'yesexpr': '^[yY].*'
} }

View File

@ -1,11 +1,13 @@
#!/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 absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en' __docformat__ = 'restructuredtext en'
from calibre.utils.magick.legacy import Image, PixelWand from calibre.utils.magick.legacy import Image, PixelWand
from polyglot.builtins import unicode_type
if False: if False:
PixelWand PixelWand
@ -13,5 +15,5 @@ if False:
def create_canvas(width, height, bgcolor='#ffffff'): def create_canvas(width, height, bgcolor='#ffffff'):
canvas = Image() canvas = Image()
canvas.create_canvas(int(width), int(height), str(bgcolor)) canvas.create_canvas(int(width), int(height), unicode_type(bgcolor))
return canvas return canvas

View File

@ -1,5 +1,6 @@
#!/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 absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'

View File

@ -1,3 +1,5 @@
from __future__ import absolute_import, division, print_function, unicode_literals
''' '''
Based on the OpenSearch Python module by Ed Summers <ehs@pobox.com> from Based on the OpenSearch Python module by Ed Summers <ehs@pobox.com> from
https://github.com/edsu/opensearch . https://github.com/edsu/opensearch .

View File

@ -1,5 +1,6 @@
#!/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 absolute_import, division, print_function, unicode_literals
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>' __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'