diff options
| author | hmeland | 2000-04-09 13:11:20 +0000 |
|---|---|---|
| committer | hmeland | 2000-04-09 13:11:20 +0000 |
| commit | 752fbddc46deec6cedd0415777f1080dec8acb23 (patch) | |
| tree | cf90fc1adf01ae389a29e859b4822224eecd1b2e /Mailman/Utils.py | |
| parent | b1c50a134bf8c748e452988bd5bb58cbcfc414a4 (diff) | |
| download | mailman-752fbddc46deec6cedd0415777f1080dec8acb23.tar.gz mailman-752fbddc46deec6cedd0415777f1080dec8acb23.tar.zst mailman-752fbddc46deec6cedd0415777f1080dec8acb23.zip | |
list_exists(): New function, returns true iff list `listname' exists.
list_names(): Use list_exists().
GetNestingLevel(): Use string.count() for counting.
Changed to explicit "from Mailman import" where appropriate.
Diffstat (limited to 'Mailman/Utils.py')
| -rw-r--r-- | Mailman/Utils.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index c7b97441e..daeeed1f7 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -32,8 +32,9 @@ from types import StringType # XXX: obsolete, should use re module import regsub import random -import mm_cfg -import Errors + +from Mailman import mm_cfg +from Mailman import Errors ##try: ## import md5 ##except ImportError: @@ -41,16 +42,19 @@ import Errors +def list_exists(listname): + """Return true iff list `listname' exists.""" + return os.path.exists( + os.path.join(mm_cfg.LIST_DATA_DIR, listname, 'config.db')) + + def list_names(): """Return the names of all lists in default list directory.""" got = [] for fn in os.listdir(mm_cfg.LIST_DATA_DIR): - if not ( - os.path.exists( - os.path.join(os.path.join(mm_cfg.LIST_DATA_DIR, fn), - 'config.db'))): - continue - got.append(fn) + if not list_exists(fn): + continue + got.append(fn) return got @@ -219,7 +223,7 @@ def GetNestingLevel(): path = os.environ['PATH_INFO'] if path[0] <> '/': path= '/' + path - _nesting_level = len(string.split(path, '/')) - 1 + _nesting_level = string.count(path, '/') except KeyError: _nesting_level = 0 return _nesting_level @@ -416,7 +420,7 @@ def map_maillists(func, names=None, unlock=None, verbose=0): Optional arg verbose says to print list name as it's about to be instantiated, CR when instantiation is complete, and result of application as it shows.""" - from MailList import MailList + from Mailman.MailList import MailList if names == None: names = list_names() got = [] |
