Skip to content

Commit d79e28e

Browse files
committed
chore: ruff spacing fixups, flow control and import reordering/removal
1 parent 97e5ddf commit d79e28e

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

roundup/scripts/roundup_mailgw.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717
"""Command-line script stub that calls the roundup.mailgw.
1818
"""
1919
from __future__ import print_function
20+
2021
__docformat__ = 'restructuredtext'
2122

2223

23-
# --- patch sys.path to make sure 'import roundup' finds correct version
24-
import sys
24+
import netrc
25+
import os
2526
import os.path as osp
27+
import re
28+
import socket
29+
import sys
2630
from argparse import ArgumentParser, RawDescriptionHelpFormatter
2731

32+
# --- patch sys.path to make sure 'import roundup' finds correct version
2833
thisdir = osp.dirname(osp.abspath(__file__))
2934
rootdir = osp.dirname(osp.dirname(thisdir))
3035
if (osp.exists(thisdir + '/__init__.py') and
@@ -33,16 +38,13 @@
3338
sys.path.insert(0, rootdir)
3439
# --/
3540

41+
# Python version check run for side effect.
42+
# Aborts program if Python version too old.
43+
from roundup import version_check # noqa: E402 F401 I001
3644

37-
# python version check
38-
from roundup import version_check
39-
from roundup import __version__ as roundup_version
40-
41-
import sys, os, re, getopt, socket, netrc
42-
43-
from roundup import mailgw
44-
from roundup.i18n import _
45-
45+
from roundup import __version__ as roundup_version # noqa: E402
46+
from roundup import mailgw # noqa: E402
47+
from roundup.i18n import _ # noqa: E402
4648

4749
usage_epilog = """
4850
The roundup mail gateway may be called in one of the following ways:
@@ -140,6 +142,7 @@
140142
141143
"""
142144

145+
143146
def parse_arguments(argv):
144147
'''Handle the arguments to the program
145148
'''
@@ -164,13 +167,14 @@ def parse_arguments(argv):
164167
'organizations/oauth2/v2.0/token')
165168
return cmd, cmd.parse_args(argv)
166169

170+
167171
def main(argv):
168172
'''Handle the arguments to the program and initialise environment.
169173
'''
170174
cmd, args = parse_arguments(argv)
171175
if args.version:
172176
print('%s (python %s)' % (roundup_version, sys.version.split()[0]))
173-
return
177+
return None
174178

175179
# figure the instance home
176180
if len(args.args) > 0:
@@ -234,17 +238,17 @@ def main(argv):
234238
if source.startswith('pop'):
235239
ssl = source.endswith('s')
236240
return handler.do_pop(server, username, password, ssl)
237-
elif source == 'apop':
241+
if source == 'apop':
238242
return handler.do_apop(server, username, password)
239-
elif source.startswith('imap'):
243+
if source.startswith('imap'):
240244
d = {}
241245
if source.endswith('s'):
242-
d.update(ssl = 1)
246+
d.update(ssl=1)
243247
elif source.endswith('s_cram'):
244-
d.update(ssl = 1, cram = 1)
248+
d.update(ssl=1, cram=1)
245249
elif source == 'imaps_oauth':
246-
d.update(ssl = 1, oauth = 1, oauth_path = args.oauth_directory)
247-
d.update(token_endpoint = args.oauth_token_endpoint)
250+
d.update(ssl=1, oauth=1, oauth_path=args.oauth_directory)
251+
d.update(token_endpoint=args.oauth_token_endpoint)
248252
mailbox = ''
249253
if len(args.args) > 3:
250254
mailbox = args.args[3]
@@ -257,7 +261,7 @@ def main(argv):
257261

258262

259263
def run():
260-
sys.exit(main(sys.argv [1:]))
264+
sys.exit(main(sys.argv[1:]))
261265

262266

263267
# call main

0 commit comments

Comments
 (0)