From c9e629b72993118fde781bed266aa2b1a7e4a088 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 14 Nov 2007 22:09:27 +0000 Subject: [PATCH] Fix regression that affected using the --url option with the default profile in web2lrf. --- src/libprs500/ebooks/lrf/web/convert_from.py | 10 +++++++--- src/libprs500/ebooks/lrf/web/profiles/__init__.py | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/libprs500/ebooks/lrf/web/convert_from.py b/src/libprs500/ebooks/lrf/web/convert_from.py index a6c1a2221c..3a967c78e3 100644 --- a/src/libprs500/ebooks/lrf/web/convert_from.py +++ b/src/libprs500/ebooks/lrf/web/convert_from.py @@ -104,13 +104,17 @@ def process_profile(args, options, logger=None): builtin_profiles.append(classes[0][1]) available_profiles.append(name) if len(args) < 2: - args.append('') + args.append(name) args[1] = name if len(args) == 2: try: - index = available_profiles.index(args[1]) + index = -1 + if args[1] != 'default': + index = available_profiles.index(args[1]) except ValueError: raise CommandLineError('Unknown profile: %s\nValid profiles: %s'%(args[1], available_profiles)) + else: + raise CommandLineError('Only one profile at a time is allowed.') profile = DefaultProfile if index == -1 else builtin_profiles[index] profile = profile(logger, options.verbose, options.username, options.password) if profile.browser is not None: @@ -159,7 +163,7 @@ def process_profile(args, options, logger=None): def main(args=sys.argv, logger=None): parser = option_parser() options, args = parser.parse_args(args) - if len(args) > 2: + if len(args) > 2 or (len(args) == 1 and not options.user_profile): parser.print_help() return 1 try: diff --git a/src/libprs500/ebooks/lrf/web/profiles/__init__.py b/src/libprs500/ebooks/lrf/web/profiles/__init__.py index 6840023dcd..deb240d09f 100644 --- a/src/libprs500/ebooks/lrf/web/profiles/__init__.py +++ b/src/libprs500/ebooks/lrf/web/profiles/__init__.py @@ -85,7 +85,10 @@ class DefaultProfile(object): self.verbose = verbose self.temp_dir = tempfile.mkdtemp(prefix=__appname__+'_') self.browser = self.get_browser() - self.url = 'file:'+ ('' if iswindows else '//') + self.build_index() + try: + self.url = 'file:'+ ('' if iswindows else '//') + self.build_index() + except NotImplementedError: + self.url = None def __del__(self): import os, shutil