From c10ae4ae3f2f9c0045de5d6459b90a1d4bcf9387 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 11 Feb 2013 08:34:04 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/oeb/polish/main.py | 6 +++--- src/calibre/ebooks/oeb/polish/stats.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/calibre/ebooks/oeb/polish/main.py b/src/calibre/ebooks/oeb/polish/main.py index 3473caacdb..fd3c2311b5 100644 --- a/src/calibre/ebooks/oeb/polish/main.py +++ b/src/calibre/ebooks/oeb/polish/main.py @@ -7,7 +7,7 @@ __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import re +import re, sys from collections import namedtuple from functools import partial @@ -122,9 +122,9 @@ def option_parser(): return parser -def main(): +def main(args=None): parser = option_parser() - opts, args = parser.parse_args() + opts, args = parser.parse_args(args or sys.argv[1:]) log = Log(level=Log.DEBUG if opts.verbose else Log.INFO) if not args: parser.print_help() diff --git a/src/calibre/ebooks/oeb/polish/stats.py b/src/calibre/ebooks/oeb/polish/stats.py index 00fad73f1b..476866c368 100644 --- a/src/calibre/ebooks/oeb/polish/stats.py +++ b/src/calibre/ebooks/oeb/polish/stats.py @@ -107,6 +107,8 @@ class Page(QWebPage): # {{{ self.js = None self.evaljs = self.mainFrame().evaluateJavaScript self.bridge_value = None + nam = self.networkAccessManager() + nam.setNetworkAccessible(nam.NotAccessible) def javaScriptConsoleMessage(self, msg, lineno, msgid): self.log(u'JS:', unicode(msg)) @@ -203,7 +205,7 @@ class StatsCollector(object): self.log.warn('Non-local URI in', warn_name, ':', href, 'ignoring') return None src = href[len('file://'):] - if iswindows and src.startswith('/'): + if iswindows and len(src) > 2 and (src[0], src[2]) == ('/', ':'): src = src[1:] src = src.replace('/', os.sep) src = unquote(src)