From 970c819e7921b3590ccbbd620e6d3ddb77e4252e Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 5 Oct 2003 12:47:19 +0000 Subject: [PATCH] Changed fix.py to munge __builtins__ rather than requiring a "from fix import *" statement. --- src/AdminCommands.py | 2 +- src/MiscCommands.py | 2 +- src/OwnerCommands.py | 2 +- src/asyncoreDrivers.py | 2 +- src/baseplugin.py | 39 +++++++++++++++++++++++++++++++-------- src/callbacks.py | 2 +- src/cdb.py | 2 +- src/conf.py | 2 +- src/debug.py | 2 +- src/drivers.py | 2 +- src/fix.py | 6 ++++-- src/ircdb.py | 2 +- src/irclib.py | 2 +- src/ircmsgs.py | 2 +- src/ircutils.py | 2 +- src/privmsgs.py | 2 +- src/schedule.py | 2 +- src/socketDrivers.py | 2 +- src/structures.py | 2 +- src/twistedDrivers.py | 2 +- src/utils.py | 2 +- src/world.py | 2 +- 22 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/AdminCommands.py b/src/AdminCommands.py index 1d13ce9f2..59be29846 100755 --- a/src/AdminCommands.py +++ b/src/AdminCommands.py @@ -34,7 +34,7 @@ These are commands useful for administrating the bot; they all require their caller to have the 'admin' capability. This plugin is loaded by default. """ -from fix import * +import fix import time import pprint diff --git a/src/MiscCommands.py b/src/MiscCommands.py index 68ba46ed1..d74228705 100755 --- a/src/MiscCommands.py +++ b/src/MiscCommands.py @@ -33,7 +33,7 @@ Miscellaneous commands. """ -from fix import * +import fix import os import sys diff --git a/src/OwnerCommands.py b/src/OwnerCommands.py index 016ceb8b3..cb24c00b5 100644 --- a/src/OwnerCommands.py +++ b/src/OwnerCommands.py @@ -34,7 +34,7 @@ Provides commands useful to the owner of the bot; the commands here require their caller to have the 'owner' capability. This plugin is loaded by default. """ -from fix import * +import fix import gc import imp diff --git a/src/asyncoreDrivers.py b/src/asyncoreDrivers.py index 28601eedd..0d60a8123 100644 --- a/src/asyncoreDrivers.py +++ b/src/asyncoreDrivers.py @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from fix import * +import fix import re import sys diff --git a/src/baseplugin.py b/src/baseplugin.py index b1124dc00..8d9bf1923 100644 --- a/src/baseplugin.py +++ b/src/baseplugin.py @@ -1,15 +1,38 @@ #!/usr/bin/env python -import sys +### +# Copyright (c) 2002, Jeremiah Fincher +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions, and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions, and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the author of this software nor the name of +# contributors to this software may be used to endorse or promote products +# derived from this software without specific prior written consent. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +### -if 'sys' not in sys.path: - sys.path.insert(0, 'src') -if 'others' not in sys.path: - sys.path.insert(0, 'others') - -from fix import * +import fix import os +import sys import sets import time import urllib2 @@ -23,7 +46,7 @@ import utils import world import ircutils -__all__ = fix.__all__ + ['ChannelDBHandler', 'PeriodicFileDownloader'] +__all__ = ['ChannelDBHandler', 'PeriodicFileDownloader'] class ChannelDBHandler(object): """A class to handle database stuff for individual channels transparently. diff --git a/src/callbacks.py b/src/callbacks.py index a17041076..cc16ad22a 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -38,7 +38,7 @@ PrivmsgRegexp class. Read their respective docstrings for more information on how to use them. """ -from fix import * +import fix import re import sets diff --git a/src/cdb.py b/src/cdb.py index 878dc0d56..7ad7252ee 100644 --- a/src/cdb.py +++ b/src/cdb.py @@ -34,7 +34,7 @@ Database module, similar to dbhash. Uses a format similar to (if not entirely the same as) DJB's CDB . """ -from fix import * +import fix import os import sys diff --git a/src/conf.py b/src/conf.py index 31543b0b9..018dbeb8d 100644 --- a/src/conf.py +++ b/src/conf.py @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from fix import * +import fix import sys diff --git a/src/debug.py b/src/debug.py index 2906a0e3d..059aa351e 100644 --- a/src/debug.py +++ b/src/debug.py @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from fix import * +import fix import sys diff --git a/src/drivers.py b/src/drivers.py index f35e5d0ca..d477c64d4 100644 --- a/src/drivers.py +++ b/src/drivers.py @@ -33,7 +33,7 @@ Contains various drivers (network, file, and otherwise) for using IRC objects. """ -from fix import * +import fix import re import os diff --git a/src/fix.py b/src/fix.py index 126db42af..e036bf2aa 100644 --- a/src/fix.py +++ b/src/fix.py @@ -29,8 +29,6 @@ # POSSIBILITY OF SUCH DAMAGE. ### -## from __future__ import generators - """ Fixes stuff that Python should have but doesn't. """ @@ -131,5 +129,9 @@ def rsplit(s, sep=None, maxsplit=-1): L.reverse() return [s[::-1] for s in L] +for name in __all__: + __builtins__[name] = globals()[name] + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: + diff --git a/src/ircdb.py b/src/ircdb.py index 1a253faa8..3d365712d 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from fix import * +import fix import os import sets diff --git a/src/irclib.py b/src/irclib.py index 49de15962..1e8deb3c2 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from fix import * +import fix from structures import queue, RingBuffer import copy diff --git a/src/ircmsgs.py b/src/ircmsgs.py index c060ff146..6d3d4ea0f 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -36,7 +36,7 @@ construct such messages in an easier way than the constructor for the IrcMsg object (which, as you'll read later, is quite...full-featured :)) """ -from fix import * +import fix import re import string diff --git a/src/ircutils.py b/src/ircutils.py index dc6c50ff3..3ee555973 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -36,7 +36,7 @@ nick class to handle nicks (so comparisons and hashing and whatnot work in an IRC-case-insensitive fashion), and numerous other things. """ -from fix import * +import fix import re import sets diff --git a/src/privmsgs.py b/src/privmsgs.py index 5b64b9c00..55f4cb61f 100644 --- a/src/privmsgs.py +++ b/src/privmsgs.py @@ -33,7 +33,7 @@ Includes various accessories for callbacks.Privmsg based callbacks. """ -from fix import * +import fix import new diff --git a/src/schedule.py b/src/schedule.py index 19e80dc3e..f777bd177 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -34,7 +34,7 @@ Schedule plugin with a subclass of drivers.IrcDriver in order to be run as a Supybot driver. """ -from fix import * +import fix import time import heapq diff --git a/src/socketDrivers.py b/src/socketDrivers.py index d8804ce8f..adb414610 100644 --- a/src/socketDrivers.py +++ b/src/socketDrivers.py @@ -35,7 +35,7 @@ Contains simple socket drivers. Asyncore bugged (haha, pun!) me. from __future__ import division -from fix import * +import fix import time import socket diff --git a/src/structures.py b/src/structures.py index 3262d871b..6469b514f 100644 --- a/src/structures.py +++ b/src/structures.py @@ -35,7 +35,7 @@ Data structures for Python. ## from __future__ import generators -from fix import * +import fix import types diff --git a/src/twistedDrivers.py b/src/twistedDrivers.py index a9d76e069..e10be8b02 100644 --- a/src/twistedDrivers.py +++ b/src/twistedDrivers.py @@ -29,7 +29,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from fix import * +import fix import time diff --git a/src/utils.py b/src/utils.py index 81fd39bd4..ca71ddadb 100755 --- a/src/utils.py +++ b/src/utils.py @@ -35,7 +35,7 @@ Simple utility functions. ## from __future__ import generators -from fix import * +import fix import os import re diff --git a/src/world.py b/src/world.py index d8758f69a..383c16b02 100644 --- a/src/world.py +++ b/src/world.py @@ -33,7 +33,7 @@ Module for general worldly stuff, like global variables and whatnot. """ -from fix import * +import fix import os import gc