comparison roundup/scripts/roundup_mailgw.py @ 5376:64b05e24dbd8

Python 3 preparation: convert print to a function. Tool-assisted patch. It is possible that some "from __future__ import print_function" are not in fact needed, if a file only uses print() with a single string as an argument and so would work fine in Python 2 without that import.
author Joseph Myers <jsm@polyomino.org.uk>
date Tue, 24 Jul 2018 09:54:52 +0000
parents 63574f1f3570
children 55f09ca366c4
comparison
equal deleted inserted replaced
5375:1ad46057ae4a 5376:64b05e24dbd8
14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 14 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
16 16
17 """Command-line script stub that calls the roundup.mailgw. 17 """Command-line script stub that calls the roundup.mailgw.
18 """ 18 """
19 from __future__ import print_function
19 __docformat__ = 'restructuredtext' 20 __docformat__ = 'restructuredtext'
20 21
21 22
22 # --- patch sys.path to make sure 'import roundup' finds correct version 23 # --- patch sys.path to make sure 'import roundup' finds correct version
23 import sys 24 import sys
41 from roundup import mailgw 42 from roundup import mailgw
42 from roundup.i18n import _ 43 from roundup.i18n import _
43 44
44 def usage(args, message=None): 45 def usage(args, message=None):
45 if message is not None: 46 if message is not None:
46 print message 47 print(message)
47 print _( 48 print(_(
48 """Usage: %(program)s [-v] [-c class] [[-C class] -S field=value]* [instance home] [mail source [specification]] 49 """Usage: %(program)s [-v] [-c class] [[-C class] -S field=value]* [instance home] [mail source [specification]]
49 50
50 Options: 51 Options:
51 -v: print version and exit 52 -v: print version and exit
52 -c: default class of item to create (else the tracker's MAIL_DEFAULT_CLASS) 53 -c: default class of item to create (else the tracker's MAIL_DEFAULT_CLASS)
121 IMAPS_CRAM: 122 IMAPS_CRAM:
122 Connect to an IMAP server over ssl using CRAM-MD5 authentication. 123 Connect to an IMAP server over ssl using CRAM-MD5 authentication.
123 This supports the same notation as IMAP. 124 This supports the same notation as IMAP.
124 imaps_cram username:password@server [mailbox] 125 imaps_cram username:password@server [mailbox]
125 126
126 """)%{'program': args[0]} 127 """)%{'program': args[0]})
127 return 1 128 return 1
128 129
129 def main(argv): 130 def main(argv):
130 '''Handle the arguments to the program and initialise environment. 131 '''Handle the arguments to the program and initialise environment.
131 ''' 132 '''
139 usage(argv) 140 usage(argv)
140 sys.exit(2) 141 sys.exit(2)
141 142
142 for (opt, arg) in optionsList: 143 for (opt, arg) in optionsList:
143 if opt == '-v': 144 if opt == '-v':
144 print '%s (python %s)'%(roundup_version, sys.version.split()[0]) 145 print('%s (python %s)'%(roundup_version, sys.version.split()[0]))
145 return 146 return
146 147
147 # figure the instance home 148 # figure the instance home
148 if len(args) > 0: 149 if len(args) > 0:
149 instance_home = args[0] 150 instance_home = args[0]

Roundup Issue Tracker: http://roundup-tracker.org/