From 442392b5baa8a941c95822cb816925e27b3d9f76 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 30 Aug 2003 19:20:08 +0000 Subject: [PATCH] Guarded inserts into sys.path. --- plugins/baseplugin.py | 6 ++++-- scripts/adduser.py | 5 ++++- scripts/newplugin.py | 4 +++- src/template.py | 4 +++- test/test.py | 11 +++++++---- tools/conv.py | 5 ++++- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/plugins/baseplugin.py b/plugins/baseplugin.py index bc4634847..d2343974f 100644 --- a/plugins/baseplugin.py +++ b/plugins/baseplugin.py @@ -2,8 +2,10 @@ import sys -sys.path.insert(0, 'src') -sys.path.insert(0, 'others') +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 * diff --git a/scripts/adduser.py b/scripts/adduser.py index ac8953bdd..dcde7dab8 100755 --- a/scripts/adduser.py +++ b/scripts/adduser.py @@ -29,7 +29,10 @@ # POSSIBILITY OF SUCH DAMAGE. ### import sys -sys.path.insert(0, 'src') + +if 'src' not in sys.path: + sys.path.insert(0, 'src') + from fix import * from questions import * diff --git a/scripts/newplugin.py b/scripts/newplugin.py index d4c182b4e..282642e0c 100755 --- a/scripts/newplugin.py +++ b/scripts/newplugin.py @@ -2,7 +2,9 @@ import os import sys -sys.path.insert(0, 'src') + +if 'src' not in sys.path: + sys.path.insert(0, 'src') from questions import * diff --git a/src/template.py b/src/template.py index f02bb123a..af928837a 100755 --- a/src/template.py +++ b/src/template.py @@ -40,7 +40,9 @@ import time import optparse started = time.time() -sys.path.insert(0, 'src') + +if 'src' not in sys.path: + sys.path.insert(0, 'src') import conf diff --git a/test/test.py b/test/test.py index cf11a1d61..2d2e45f90 100755 --- a/test/test.py +++ b/test/test.py @@ -30,14 +30,17 @@ ### import sys -sys.path.insert(0, 'src') -sys.path.insert(0, 'test') -sys.path.insert(0, 'plugins') - +if 'src' not in sys.path: + sys.path.insert(0, 'src') +if 'test' not in sys.path: + sys.path.insert(0, 'test') import conf conf.dataDir = 'test-data' +if conf.pluginDir not in sys.path: + sys.path.insert(0, conf.pluginDir) + from fix import * import gc diff --git a/tools/conv.py b/tools/conv.py index b24ba4bb9..f8f8d4568 100644 --- a/tools/conv.py +++ b/tools/conv.py @@ -5,7 +5,10 @@ Converts from a "key => value\n" format to a cdb database. """ import sys -sys.path.insert(0, 'src') + +if 'src' not in sys.path: + sys.path.insert(0, 'src') + import re import cdb