Skip to content

Commit d351c03

Browse files
authored
Reformatting to clear several linter recommendations
1 parent 3b10afd commit d351c03

8 files changed

Lines changed: 22 additions & 23 deletions

File tree

courier/control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def del_recipient(control_paths, recipient):
280280
rcpts = _get_recipients_from_file(control_path)
281281
for rcpt in rcpts:
282282
if (rcpt[1] is False # Delivery is not complete for this recipient
283-
and rcpt[2][0] == recipient):
283+
and rcpt[2][0] == recipient):
284284
_mark_complete(control_path, rcpt[0])
285285
return
286286

@@ -306,7 +306,7 @@ def del_recipient_data(control_paths, recipient_data):
306306
rcpts = _get_recipients_from_file(cf)
307307
for x in rcpts:
308308
if (x[1] is False # Delivery is not complete for this recipient
309-
and x[2] == recipient_data):
309+
and x[2] == recipient_data):
310310
_mark_complete(cf, x[0])
311311
return
312312

courier/quarantine.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def send_notice(message, address, sender=None):
7373
# available, or if it is present and a true value.
7474
rcpts = []
7575
if ('notify_recipient' not in config
76-
or config['notify_recipient']):
76+
or config['notify_recipient']):
7777
rcpts.append(address)
7878
if 'also_notify' in config and config['also_notify']:
7979
rcpts.append(config['also_notify'])
@@ -123,9 +123,9 @@ def quarantine(body_path, control_paths, explanation):
123123
# Some sites would prefer that only admins release messages from the
124124
# quarantine.
125125
if ('user_release' in config
126-
and config['user_release'] == 0
127-
and 'also_notify' in config
128-
and config['also_notify']):
126+
and config['user_release'] == 0
127+
and 'also_notify' in config
128+
and config['also_notify']):
129129
release_addr = config['also_notify']
130130
else:
131131
release_addr = 'quarantine-%s-%s@%s' % (config['siteid'],
@@ -137,7 +137,7 @@ def quarantine(body_path, control_paths, explanation):
137137
try:
138138
with open(body_path, 'rb') as body_file:
139139
qmessage = email.message_from_binary_file(body_file)
140-
except Exception as e:
140+
except Exception:
141141
# TODO: Handle this error.
142142
raise # InitError('Internal failure parsing message data file: %s' % str(e))
143143
qmessage_sender = qmessage['from']
@@ -189,8 +189,8 @@ def release(requested_id, address):
189189
return
190190
for x in courier.control.get_control_data(quarantine_paths[1])['r']:
191191
if (x[0] == address or
192-
x[1] == address or
193-
x[1] == '%s%s' % ('rfc822;', address)):
192+
x[1] == address or
193+
x[1] == '%s%s' % ('rfc822;', address)):
194194
courier.sendmail.sendmail('', address, open(quarantine_paths[0], 'rb').readlines())
195195
return
196196
# If no address matched, alert the user that the request was invalid.

dropmsg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def usage():
3636
-s: Messages with the given envelope sender's address or DSNs to that address''' % quarantine)
3737

3838

39-
4039
def drop(cf, df):
4140
qcf = os.path.join(quarantine, os.path.basename(cf))
4241
qdf = os.path.join(quarantine, os.path.basename(df))
@@ -98,5 +97,6 @@ def main():
9897

9998
search(auth, ip, sender)
10099

100+
101101
if __name__ == '__main__':
102102
main()

filters/pythonfilter/deliveredto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def do_filter(body_path, control_paths):
4545
if len(dparts) != 2:
4646
return ''
4747
if (courier.config.is_local(dparts[1]) or
48-
courier.config.is_hosteddomain(dparts[1])):
48+
courier.config.is_hosteddomain(dparts[1])):
4949
return '501 Mail loop - already have my Delivered-To: header.'
5050
return ''
5151

filters/pythonfilter/localsenders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def do_filter(body_path, control_paths):
5353
if sender_info is None:
5454
return '517 Sender does not exist: %s' % sender
5555
if (require_auth and
56-
courier.control.get_auth_user(control_paths, body_path) is None):
56+
courier.control.get_auth_user(control_paths, body_path) is None):
5757
return '517 Policy requires local senders to authenticate.'
5858
return ''
5959

filters/pythonfilter/whitelist_dnswl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def do_filter(body_path, control_paths):
5252
sys.stderr.write(f'whitelist_dnswl: unparsable senders_ip: {senders_ip}\n')
5353
return ''
5454

55-
# sender is either IPV4Address or IPV6Address object,
55+
# sender is either IPV4Address or IPV6Address object
5656
reverse = sender.reverse_pointer.replace('.in-addr.arpa', '').replace('.ip6.arpa', '')
5757

5858
for zone in dnswl_zone:

pythonfilter

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,10 @@ def log_file_codes(module, reply_code, control_paths):
344344

345345

346346
def wait_for_message(filter_socket, filters, active_filters):
347-
try: ready_files = select.select([sys.stdin, filter_socket], [], [])
348-
except Exception: return True
347+
try:
348+
ready_files = select.select([sys.stdin, filter_socket], [], [])
349+
except Exception:
350+
return True
349351
# If stdin raised an event, it was closed and we need to exit.
350352
if sys.stdin in ready_files[0]:
351353
return False
@@ -377,7 +379,7 @@ def close_socket(filter_socket_path, filter_socket):
377379

378380
def wait_for_active_filters(active_filters):
379381
deadline = time.time() + 10
380-
while(active_filters.count > 0 and time.time() < deadline):
382+
while (active_filters.count > 0 and time.time() < deadline):
381383
# Wait for them all to finish
382384
time.sleep(0.1)
383385

tests/test_control.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@
1818
# along with pythonfilter. If not, see <http://www.gnu.org/licenses/>.
1919

2020
import os
21-
import unittest
2221
import shutil
23-
import courier.config
24-
25-
26-
courier.config.sysconfdir = 'tmp/configfiles'
27-
22+
import unittest
2823

24+
import courier.config
2925
import courier.control
3026

27+
courier.config.sysconfdir = 'tmp/configfiles'
3128

3229
message = {}
3330
message['xalias'] = {'control_paths': [f'{os.path.dirname(__file__)}/tmp/queuefiles/control-xalias'],
@@ -79,7 +76,7 @@
7976
'rfc822;postmaster@ascension.private.dragonsdawn.net',
8077
'']]},
8178
'senders_ip': '127.0.0.1'}
82-
message['ldapalias'] = {'control_paths': [f'{os.path.dirname(__file__)}/tmp/queuefiles/control-ldapalias'],
79+
message['ldapalias'] = {'control_paths': [f'{os.path.dirname(__file__)}/tmp/queuefiles/control-ldapalias'],
8380
'control_data': {'s': 'root@ascension.private.dragonsdawn.net',
8481
'f': 'dns; localhost (localhost [127.0.0.1])',
8582
'e': '',

0 commit comments

Comments
 (0)