mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
py3: More unicode_literals and str() porting
This commit is contained in:
parent
f3b64dfbe2
commit
da404870ca
@ -1,10 +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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
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>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2011, Ken <ken at szboeye.com>'
|
__copyright__ = '2011, Ken <ken at szboeye.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Kovid Goyal'
|
__copyright__ = '2009, Kovid Goyal'
|
||||||
@ -36,5 +37,3 @@ class EDGE(USBMS):
|
|||||||
|
|
||||||
EBOOK_DIR_MAIN = 'download'
|
EBOOK_DIR_MAIN = 'download'
|
||||||
SUPPORTS_SUB_DIRS = True
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Created on 15 May 2010
|
Created on 15 May 2010
|
||||||
|
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
|
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
|
__copyright__ = '2009, Tijmen Ruizendaal <tijmen at mybebook.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,10 +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'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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>'
|
||||||
@ -41,5 +41,3 @@ class IRIVER_STORY(USBMS):
|
|||||||
EBOOK_DIR_MAIN = 'Book'
|
EBOOK_DIR_MAIN = 'Book'
|
||||||
|
|
||||||
SUPPORTS_SUB_DIRS = True
|
SUPPORTS_SUB_DIRS = True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, James Ralston <jralston at mindspring.com>'
|
__copyright__ = '2009, James Ralston <jralston at mindspring.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -10,8 +12,8 @@ Device driver for Ectaco Jetbook firmware >= JL04_v030e
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
|
from calibre.constants import filesystem_encoding
|
||||||
from calibre.devices.usbms.driver import USBMS
|
from calibre.devices.usbms.driver import USBMS
|
||||||
from calibre.ebooks.metadata import string_to_authors
|
from calibre.ebooks.metadata import string_to_authors
|
||||||
from polyglot.builtins import unicode_type, map
|
from polyglot.builtins import unicode_type, map
|
||||||
@ -64,10 +66,9 @@ class JETBOOK(USBMS):
|
|||||||
def metadata_from_path(cls, path):
|
def metadata_from_path(cls, path):
|
||||||
|
|
||||||
def check_unicode(txt):
|
def check_unicode(txt):
|
||||||
txt = txt.replace('_', ' ')
|
|
||||||
if not isinstance(txt, unicode_type):
|
if not isinstance(txt, unicode_type):
|
||||||
return txt.decode(sys.getfilesystemencoding(), 'replace')
|
txt = txt.decode(filesystem_encoding, 'replace')
|
||||||
|
txt = txt.replace('_', ' ')
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
mi = cls.metadata_from_formats([path])
|
mi = cls.metadata_from_formats([path])
|
||||||
|
@ -227,7 +227,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
|||||||
try:
|
try:
|
||||||
storage = sorted(self.dev.storage_info, key=operator.itemgetter('id'))
|
storage = sorted(self.dev.storage_info, key=operator.itemgetter('id'))
|
||||||
except self.libmtp.MTPError as e:
|
except self.libmtp.MTPError as e:
|
||||||
if "The device has no storage information." in str(e):
|
if "The device has no storage information." in unicode_type(e):
|
||||||
# This happens on newer Android devices while waiting for
|
# This happens on newer Android devices while waiting for
|
||||||
# the user to allow access. Apparently what happens is
|
# the user to allow access. Apparently what happens is
|
||||||
# that when the user clicks allow, the device disconnects
|
# that when the user clicks allow, the device disconnects
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009-2014, John Schember <john at nachtimwald.com> and Andres Gomez <agomez at igalia.com>'
|
__copyright__ = '2009-2014, John Schember <john at nachtimwald.com> and Andres Gomez <agomez at igalia.com>'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# 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>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
|
@ -1,10 +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__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
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'
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@ -102,6 +102,6 @@ class CLI(object):
|
|||||||
def touch(self, path, end_session=True):
|
def touch(self, path, end_session=True):
|
||||||
path = self.munge_path(path)
|
path = self.munge_path(path)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
lopen(path, 'w').close()
|
lopen(path, 'wb').close()
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
os.utime(path, None)
|
os.utime(path, None)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com> ' \
|
__copyright__ = '2009, John Schember <john at nachtimwald.com> ' \
|
||||||
'2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
'2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
@ -243,9 +243,9 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
try:
|
try:
|
||||||
dlmap = get_drive_letters_for_device(usbdev, debug=debug)
|
dlmap = get_drive_letters_for_device(usbdev, debug=debug)
|
||||||
except Exception:
|
except Exception:
|
||||||
dlmap = []
|
dlmap = {}
|
||||||
|
|
||||||
if not dlmap['drive_letters']:
|
if not dlmap.get('drive_letters'):
|
||||||
time.sleep(7)
|
time.sleep(7)
|
||||||
dlmap = get_drive_letters_for_device(usbdev, debug=debug)
|
dlmap = get_drive_letters_for_device(usbdev, debug=debug)
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
if not os.access(j(usb_dir, y), os.R_OK):
|
if not os.access(j(usb_dir, y), os.R_OK):
|
||||||
usb_dir = None
|
usb_dir = None
|
||||||
continue
|
continue
|
||||||
e = lambda q : raw2num(open(j(usb_dir, q)).read())
|
e = lambda q : raw2num(open(j(usb_dir, q), 'rb').read().decode('utf-8'))
|
||||||
ven, prod, bcd = map(e, ('idVendor', 'idProduct', 'bcdDevice'))
|
ven, prod, bcd = map(e, ('idVendor', 'idProduct', 'bcdDevice'))
|
||||||
if not (test(ven, 'idVendor') and test(prod, 'idProduct') and
|
if not (test(ven, 'idVendor') and test(prod, 'idProduct') and
|
||||||
test(bcd, 'bcdDevice')):
|
test(bcd, 'bcdDevice')):
|
||||||
@ -489,7 +489,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
sz = j(x, 'size')
|
sz = j(x, 'size')
|
||||||
node = parts[idx+1]
|
node = parts[idx+1]
|
||||||
try:
|
try:
|
||||||
exists = int(open(sz).read()) > 0
|
exists = int(open(sz, 'rb').read().decode('utf-8')) > 0
|
||||||
if exists:
|
if exists:
|
||||||
node = self.find_largest_partition(x)
|
node = self.find_largest_partition(x)
|
||||||
ok[node] = True
|
ok[node] = True
|
||||||
@ -523,7 +523,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
if not os.access(sz, os.R_OK):
|
if not os.access(sz, os.R_OK):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
sz = int(open(sz).read())
|
sz = int(open(sz, 'rb').read().decode('utf-8'))
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if sz > 0:
|
if sz > 0:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL 3'
|
__license__ = 'GPL 3'
|
||||||
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john@nachtimwald.com>'
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
__copyright__ = '2009, John Schember <john at nachtimwald.com>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user