1414# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1515# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1616#
17- # $Id: roundup_mailgw.py,v 1.24 2008-08-19 01:01:32 richard Exp $
17+ # $Id: roundup_mailgw.py,v 1.25 2008-08-19 01:06:01 richard Exp $
1818
1919"""Command-line script stub that calls the roundup.mailgw.
2020"""
@@ -165,8 +165,10 @@ def main(argv):
165165 if source == 'mailbox' :
166166 return handler .do_mailbox (specification )
167167
168- # Try parsing the netrc file first.
168+ # the source will be a network server, so obtain the credentials to
169+ # use in connecting to the server
169170 try :
171+ # attempt to obtain credentials from a ~/.netrc file
170172 authenticator = netrc .netrc ().authenticators (specification )
171173 username = authenticator [0 ]
172174 password = authenticator [2 ]
@@ -183,22 +185,23 @@ def main(argv):
183185 else :
184186 return usage (argv , _ ('Error: %s specification not valid' ) % source )
185187
186- if source == 'pop' or source == 'pops' :
188+ # now invoke the mailgw handler depending on the server handler requested
189+ if source .startswith ('pop' ):
187190 ssl = source .endswith ('s' )
188191 if ssl and sys .version_info < (2 ,4 ):
189192 return usage (argv , _ ('Error: a later version of python is required' ))
190193 return handler .do_pop (server , username , password , ssl )
191194 elif source == 'apop' :
192195 return handler .do_apop (server , username , password )
193- elif source == 'imap' or source == 'imaps' :
196+ elif source . startswith ( 'imap' ) :
194197 ssl = source .endswith ('s' )
195198 mailbox = ''
196199 if len (args ) > 3 :
197200 mailbox = args [3 ]
198201 return handler .do_imap (server , username , password , mailbox , ssl )
199202
200203 return usage (argv , _ ('Error: The source must be either "mailbox",'
201- ' "pop", "apop", "imap" or "imaps"' ))
204+ ' "pop", "pops", " apop", "imap" or "imaps"' ))
202205 finally :
203206 # handler might have closed the initial db and opened a new one
204207 handler .db .close ()
0 commit comments