delay load urllib

This commit is contained in:
Kovid Goyal 2013-05-02 18:46:42 +05:30
parent 04090c8e6f
commit edb84a621a
8 changed files with 9 additions and 8 deletions

View File

@ -1761,7 +1761,7 @@ if __name__ == '__main__':
for x in ('lxml', 'calibre.ebooks.BeautifulSoup', 'uuid',
'calibre.utils.terminal', 'calibre.utils.magick', 'PIL', 'Image',
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect'):
'sqlite3', 'mechanize', 'httplib', 'xml', 'inspect', 'urllib'):
if x in sys.modules:
ret = 1
print (x, 'has been loaded by a plugin')

View File

@ -10,7 +10,6 @@ __docformat__ = 'restructuredtext en'
import re, tempfile, os
from functools import partial
from itertools import izip
from urllib import quote
from calibre.constants import islinux, isbsd
from calibre.customize.conversion import (InputFormatPlugin,
@ -223,6 +222,7 @@ class HTMLInput(InputFormatPlugin):
return link, frag
def resource_adder(self, link_, base=None):
from urllib import quote
link, frag = self.link_to_local_path(link_, base=base)
if link is None:
return link_

View File

@ -7,7 +7,6 @@ __docformat__ = 'restructuredtext en'
Provides abstraction for metadata reading.writing from a variety of ebook formats.
"""
import os, sys, re
from urllib import unquote, quote
from urlparse import urlparse
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):
from urllib import unquote
self._href = None
self._basedir = basedir
self.path = None
@ -226,6 +226,7 @@ class Resource(object):
`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.
'''
from urllib import quote
if basedir is None:
if self._basedir:
basedir = self._basedir

View File

@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import socket, time, re
from urllib import urlencode
from threading import Thread
from Queue import Queue, Empty
@ -637,6 +636,7 @@ class Amazon(Source):
def create_query(self, log, title=None, authors=None, identifiers={}, # {{{
domain=None):
from urllib import urlencode
if domain is None:
domain = self.domain

View File

@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>; 2011, Li Fanxi <lifan
__docformat__ = 'restructuredtext en'
import time
from urllib import urlencode
from functools import partial
from Queue import Queue, Empty
@ -172,6 +171,7 @@ class Douban(Source):
# }}}
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
from urllib import urlencode
SEARCH_URL = 'http://api.douban.com/book/subjects?'
ISBN_URL = 'http://api.douban.com/book/subject/isbn/'
SUBJECT_URL = 'http://api.douban.com/book/subject/'

View File

@ -8,7 +8,6 @@ __copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
import time, hashlib
from urllib import urlencode
from functools import partial
from Queue import Queue, Empty
@ -179,6 +178,7 @@ class GoogleBooks(Source):
# }}}
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
from urllib import urlencode
BASE_URL = 'http://books.google.com/books/feeds/volumes?'
isbn = check_isbn(identifiers.get('isbn', None))
q = ''

View File

@ -7,7 +7,6 @@ __license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'
from urllib import quote
from calibre.ebooks.metadata import check_isbn
@ -66,6 +65,7 @@ class ISBNDB(Source):
return self.isbndb_key is not None
def create_query(self, title=None, authors=None, identifiers={}): # {{{
from urllib import quote
base_url = BASE_URL%self.isbndb_key
isbn = check_isbn(identifiers.get('isbn', None))
q = ''

View File

@ -6,7 +6,6 @@ __copyright__ = '2011, Roman Mukhin <ramses_ru at hotmail.com>'
__docformat__ = 'restructuredtext en'
import re
from urllib import quote_plus
from Queue import Queue, Empty
from calibre import as_unicode
@ -49,6 +48,7 @@ class Ozon(Source):
# }}}
def create_query(self, log, title=None, authors=None, identifiers={}): # {{{
from urllib import quote_plus
# div_book -> search only books, ebooks and audio books
search_url = self.ozon_url + '/webservice/webservice.asmx/SearchWebService?searchContext=div_book&searchText='