Fully qualify the call to universalImport so we don't get a NameError.

Also added some ImportError handlers to aid letting users of distribution
packages know if the distributions strip out the local module copies.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-03-19 20:33:17 -04:00
parent 843b6d0d02
commit 7b906fbf54
3 changed files with 16 additions and 4 deletions

View File

@ -37,7 +37,7 @@ import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
try: try:
dictclient = universalImport('dictclient', 'local.dictclient') dictclient = utils.python.universalImport('dictclient', 'local.dictclient')
except ImportError: except ImportError:
raise callbacks.Error, \ raise callbacks.Error, \
'You need to have dictclient installed to use this plugin. ' \ 'You need to have dictclient installed to use this plugin. ' \

View File

@ -1,6 +1,6 @@
### ###
# Copyright (c) 2002-2004, Jeremiah Fincher # Copyright (c) 2002-2004, Jeremiah Fincher
# Copyright (c) 2008, James Vega # Copyright (c) 2008-2009, James Vega
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -42,7 +42,14 @@ import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
simplejson = universalImport('json', 'simplejson', 'local.simplejson') try:
simplejson = utils.python.universalImport('json', 'simplejson',
'local.simplejson')
except ImportError:
raise callbacks.Error, \
'You need Python2.6 or the simplejson module installed to use ' \
'this plugin. Download the module at ' \
'<http://undefined.org/python/#simplejson>.'
class Google(callbacks.PluginRegexp): class Google(callbacks.PluginRegexp):
threaded = True threaded = True

View File

@ -42,7 +42,12 @@ import supybot.ircutils as ircutils
import supybot.registry as registry import supybot.registry as registry
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
try:
feedparser = utils.python.universalImport('feedparser', 'local.feedparser') feedparser = utils.python.universalImport('feedparser', 'local.feedparser')
except ImportError:
raise callbacks.Error, \
'You the feedparser module installed to use this plugin. ' \
'Download the module at <http://feedparser.org/>.'
def getFeedName(irc, msg, args, state): def getFeedName(irc, msg, args, state):
if not registry.isValidRegistryName(args[0]): if not registry.isValidRegistryName(args[0]):