From adcaf770e580027a1e4a827327af6df2620fdf55 Mon Sep 17 00:00:00 2001 From: calvin Date: Tue, 11 Jan 2005 10:43:21 +0000 Subject: [PATCH] optional optcomplete git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2123 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkchecker | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/linkchecker b/linkchecker index 90be3258..c8c92ef6 100755 --- a/linkchecker +++ b/linkchecker @@ -39,11 +39,15 @@ import linkcheck # initialize i18n, puts _() function into global namespace linkcheck.init_i18n() import linkcheck.log -import optcomplete import linkcheck.checker import linkcheck.checker.cache import linkcheck.checker.consumer import linkcheck.configuration +try: + import optcomplete + has_optcomplete = True +except ImportError: + has_optcomplete = False # default profiling filename @@ -220,8 +224,8 @@ class LCOptionParser (optparse.OptionParser, object): def print_help (self, file=None): """print translated help text""" - s = "%s\n%s\n%s"%(self.format_help(), Notes, Examples) - if os.name!='posix': + s = "%s\n%s\n%s" % (self.format_help(), Notes, Examples) + if os.name != 'posix': linkcheck.StringUtil.paginate(s) else: print s @@ -394,7 +398,8 @@ group.add_option("--status", action="store_true", dest="status", optparser.add_option_group(group) ################# auto completion ##################### -optcomplete.autocomplete(optparser) +if has_optcomplete: + optcomplete.autocomplete(optparser) # read and parse command line options and arguments (options, args) = optparser.parse_args()