summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-13 17:05:29 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-05-30 14:50:55 +0200
commita91eae7fb743a09d52abe607f5e5b7b23cf762ef (patch)
tree4b0225d33d5574ed1638962625f29952f389ed67 /pykolab
parent51a22f50389e429fe8eef84f423e7cdbe1fa6499 (diff)
downloadpykolab-a91eae7fb743a09d52abe607f5e5b7b23cf762ef.tar.gz
Correct cmd_list_mailboxes
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/cli/cmd_list_mailboxes.py31
1 files changed, 25 insertions, 6 deletions
diff --git a/pykolab/cli/cmd_list_mailboxes.py b/pykolab/cli/cmd_list_mailboxes.py
index 35e7a7b..185dea2 100644
--- a/pykolab/cli/cmd_list_mailboxes.py
+++ b/pykolab/cli/cmd_list_mailboxes.py
@@ -21,15 +21,19 @@ import commands
import pykolab
+from pykolab.imap import IMAP
from pykolab.translate import _
log = pykolab.getLogger('pykolab.cli')
conf = pykolab.getConf()
def __init__():
- commands.register('list_mailboxes', execute, description="List mailboxes.\n" + \
+ commands.register('list_mailboxes', execute, description=description(), aliases='lm')
+
+def description():
+ return "List mailboxes.\n" + \
"%-28s" % ('') + \
- "Use wildcards '*' and '%' for more control.\n")
+ "Use wildcards '*' and '%' for more control.\n"
def cli_options():
my_option_group = conf.add_cli_parser_option_group(_("CLI Options"))
@@ -43,17 +47,32 @@ def execute(*args, **kw):
"""
List mailboxes
"""
- try:
- searches = [ conf.cli_args.pop(1) ]
- except IndexError, e:
- #searches = [ 'DELETED/*', 'shared/*', 'user/*' ]
+
+ searches = []
+
+ # See if conf.cli_args components make sense.
+ for arg in conf.cli_args:
+ if arg == '*':
+ searches.append(arg)
+ if arg.startswith('user'):
+ searches.append(arg)
+ if arg.startswith('shared'):
+ searches.append(arg)
+ if arg.startswith('DELETED'):
+ searches.append(arg)
+ if arg.startswith('news'):
+ searches.append(arg)
+
+ if len(searches) == 0:
searches = [ '' ]
+ imap = IMAP()
imap.connect()
folders = []
for search in searches:
+ log.debug(_("Appending folder search for %r") % (search), level=8)
folders.extend(imap.lm(search))
for folder in folders: