diff options
| author | bwarsaw | 2006-12-29 22:20:25 +0000 |
|---|---|---|
| committer | bwarsaw | 2006-12-29 22:20:25 +0000 |
| commit | f4a456a83b630feb294724ab462c87ca1ce1c3ae (patch) | |
| tree | c5c88540dae8306d11671f603d8975b01803ea16 /Mailman/Utils.py | |
| parent | ae185106a624bfa7888aa8722d35194d3c5150e8 (diff) | |
| download | mailman-f4a456a83b630feb294724ab462c87ca1ce1c3ae.tar.gz mailman-f4a456a83b630feb294724ab462c87ca1ce1c3ae.tar.zst mailman-f4a456a83b630feb294724ab462c87ca1ce1c3ae.zip | |
Diffstat (limited to 'Mailman/Utils.py')
| -rw-r--r-- | Mailman/Utils.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index edbf25f31..d89d45f59 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -40,6 +40,7 @@ from email.Errors import HeaderParseError from string import ascii_letters, digits, whitespace from Mailman import Errors +from Mailman import database from Mailman.SafeDict import SafeDict from Mailman.configuration import config @@ -50,12 +51,13 @@ except NameError: from sets import Set as set -EMPTYSTRING = '' -UEMPTYSTRING = u'' +AT = '@' CR = '\r' -NL = '\n' DOT = '.' +EMPTYSTRING = '' IDENTCHARS = ascii_letters + digits + '_' +NL = '\n' +UEMPTYSTRING = u'' # Search for $(identifier)s strings, except that the trailing s is optional, # since that's a common mistake @@ -67,28 +69,26 @@ log = logging.getLogger('mailman.error') -def list_exists(listname): - """Return true iff list `listname' exists.""" - # The existance of any of the following file proves the list exists - # <wink>: config.pck, config.pck.last, config.db, config.db.last - # - # The former two are for 2.1alpha3 and beyond, while the latter two are - # for all earlier versions. - basepath = os.path.join(config.LIST_DATA_DIR, listname) - for ext in ('.pck', '.pck.last', '.db', '.db.last'): - dbfile = os.path.join(basepath, 'config' + ext) - if os.path.exists(dbfile): - return True - return False +def list_exists(fqdn_listname): + """Return true iff list `fqdn_listname' exists.""" + listname, hostname = split_listname(fqdn_listname) + return bool(database.find_list(listname, hostname)) def list_names(): - """Return the names of all lists in default list directory.""" - got = set() - for fn in os.listdir(config.LIST_DATA_DIR): - if list_exists(fn): - got.add(fn) - return got + """Return the fqdn names of all lists in default list directory.""" + return ['%s@%s' % (listname, hostname) + for listname, hostname in database.get_list_names()] + + +def split_listname(listname): + if AT in listname: + return listname.split(AT, 1) + return listname, config.DEFAULT_EMAIL_HOST + + +def fqdn_listname(listname): + return AT.join(split_listname(listname)) |
