mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
delay load urllib
This commit is contained in:
parent
04090c8e6f
commit
edb84a621a
@ -1761,7 +1761,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
|
for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
|
||||||
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
|
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
|
||||||
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect'):
|
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect', 'urllib'):
|
||||||
if x in sys.modules:
|
if x in sys.modules:
|
||||||
ret = 1
|
ret = 1
|
||||||
print (x, 'has been loaded by a plugin')
|
print (x, 'has been loaded by a plugin')
|
||||||
|
@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import re, tempfile, os
|
import re, tempfile, os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from itertools import izip
|
from itertools import izip
|
||||||
from urllib import quote
|
|
||||||
|
|
||||||
from calibre.constants import islinux, isbsd
|
from calibre.constants import islinux, isbsd
|
||||||
from calibre.customize.conversion import (InputFormatPlugin,
|
from calibre.customize.conversion import (InputFormatPlugin,
|
||||||
@ -223,6 +222,7 @@ class HTMLInput(InputFormatPlugin):
|
|||||||
return link, frag
|
return link, frag
|
||||||
|
|
||||||
def resource_adder(self, link_, base=None):
|
def resource_adder(self, link_, base=None):
|
||||||
|
from urllib import quote
|
||||||
link, frag = self.link_to_local_path(link_, base=base)
|
link, frag = self.link_to_local_path(link_, base=base)
|
||||||
if link is None:
|
if link is None:
|
||||||
return link_
|
return link_
|
||||||
|
@ -7,7 +7,6 @@ __docformat__ = 'restructuredtext en'
|
|||||||
Provides abstraction for metadata reading.writing from a variety of ebook formats.
|
Provides abstraction for metadata reading.writing from a variety of ebook formats.
|
||||||
"""
|
"""
|
||||||
import os, sys, re
|
import os, sys, re
|
||||||
from urllib import unquote, quote
|
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
from calibre import relpath, guess_type, remove_bracketed_text, prints
|
from calibre import relpath, guess_type, remove_bracketed_text, prints
|
||||||
@ -188,6 +187,7 @@ class Resource(object):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, href_or_path, basedir=os.getcwdu(), is_path=True):
|
def __init__(self, href_or_path, basedir=os.getcwdu(), is_path=True):
|
||||||
|
from urllib import unquote
|
||||||
self._href = None
|
self._href = None
|
||||||
self._basedir = basedir
|
self._basedir = basedir
|
||||||
self.path = None
|
self.path = None
|
||||||
@ -226,6 +226,7 @@ class Resource(object):
|
|||||||
`basedir`: If None, the basedir of this resource is used (see :method:`set_basedir`).
|
`basedir`: If None, the basedir of this resource is used (see :method:`set_basedir`).
|
||||||
If this resource has no basedir, then the current working directory is used as the basedir.
|
If this resource has no basedir, then the current working directory is used as the basedir.
|
||||||
'''
|
'''
|
||||||
|
from urllib import quote
|
||||||
if basedir is None:
|
if basedir is None:
|
||||||
if self._basedir:
|
if self._basedir:
|
||||||
basedir = self._basedir
|
basedir = self._basedir
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import socket, time, re
|
import socket, time, re
|
||||||
from urllib import urlencode
|
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
@ -637,6 +636,7 @@ class Amazon(Source):
|
|||||||
|
|
||||||
def create_query(self, log, title=None, authors=None, identifiers={}, # {{{
|
def create_query(self, log, title=None, authors=None, identifiers={}, # {{{
|
||||||
domain=None):
|
domain=None):
|
||||||
|
from urllib import urlencode
|
||||||
if domain is None:
|
if domain is None:
|
||||||
domain = self.domain
|
domain = self.domain
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>; 2011, Li Fanxi <lifan
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from urllib import urlencode
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
@ -172,6 +171,7 @@ class Douban(Source):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
||||||
|
from urllib import urlencode
|
||||||
SEARCH_URL = 'http://api.douban.com/book/subjects?'
|
SEARCH_URL = 'http://api.douban.com/book/subjects?'
|
||||||
ISBN_URL = 'http://api.douban.com/book/subject/isbn/'
|
ISBN_URL = 'http://api.douban.com/book/subject/isbn/'
|
||||||
SUBJECT_URL = 'http://api.douban.com/book/subject/'
|
SUBJECT_URL = 'http://api.douban.com/book/subject/'
|
||||||
|
@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import time, hashlib
|
import time, hashlib
|
||||||
from urllib import urlencode
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
@ -179,6 +178,7 @@ class GoogleBooks(Source):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
||||||
|
from urllib import urlencode
|
||||||
BASE_URL = 'http://books.google.com/books/feeds/volumes?'
|
BASE_URL = 'http://books.google.com/books/feeds/volumes?'
|
||||||
isbn = check_isbn(identifiers.get('isbn', None))
|
isbn = check_isbn(identifiers.get('isbn', None))
|
||||||
q = ''
|
q = ''
|
||||||
|
@ -7,7 +7,6 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from urllib import quote
|
|
||||||
|
|
||||||
|
|
||||||
from calibre.ebooks.metadata import check_isbn
|
from calibre.ebooks.metadata import check_isbn
|
||||||
@ -66,6 +65,7 @@ class ISBNDB(Source):
|
|||||||
return self.isbndb_key is not None
|
return self.isbndb_key is not None
|
||||||
|
|
||||||
def create_query(self, title=None, authors=None, identifiers={}): # {{{
|
def create_query(self, title=None, authors=None, identifiers={}): # {{{
|
||||||
|
from urllib import quote
|
||||||
base_url = BASE_URL%self.isbndb_key
|
base_url = BASE_URL%self.isbndb_key
|
||||||
isbn = check_isbn(identifiers.get('isbn', None))
|
isbn = check_isbn(identifiers.get('isbn', None))
|
||||||
q = ''
|
q = ''
|
||||||
|
@ -6,7 +6,6 @@ __copyright__ = '2011, Roman Mukhin <ramses_ru at hotmail.com>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from urllib import quote_plus
|
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
@ -49,6 +48,7 @@ class Ozon(Source):
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
|
||||||
|
from urllib import quote_plus
|
||||||
# div_book -> search only books, ebooks and audio books
|
# div_book -> search only books, ebooks and audio books
|
||||||
search_url = self.ozon_url + '/webservice/webservice.asmx/SearchWebService?searchContext=div_book&searchText='
|
search_url = self.ozon_url + '/webservice/webservice.asmx/SearchWebService?searchContext=div_book&searchText='
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user