diff options
Diffstat (limited to 'src/news2mail.py')
-rw-r--r-- | src/news2mail.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/news2mail.py b/src/news2mail.py index f99b0d7..001c8b5 100644 --- a/src/news2mail.py +++ b/src/news2mail.py @@ -26,15 +26,17 @@ import argparse from collections import OrderedDict import email import email.policy +import os import smtplib from socket import gethostbyaddr, gethostname import sys import time +import whitelist import mail2news # logging.basicConfig(level=logging.DEBUG) -class news2mail(object): +class news2mail(): """news to mail gateway class""" def __init__(self, verbose=False): @@ -59,8 +61,8 @@ class news2mail(object): """add new header like X-Gateway: Received: """ - msg['X-Gateway'] = 'pyg {0} {1}'.format(mail2news.__version__, - mail2news.__description__) + msg['X-Gateway'] = f'pyg {mail2news.__version__}' + \ + ' {mail2news.__description__}' # to make Received: header t = time.ctime(time.time()) @@ -178,8 +180,8 @@ def parse_cmdline(a_in): return (test,verbose) boolean tuple """ parser = argparse.ArgumentParser( - description='pyg version %s - Copyright 2000 Cosimo Alfarano\n%s' % - (mail2news.__version__, mail2news.__description__)) + description=f'pyg version {mail2news.__version__} - Copyright 2000 Cosimo Alfarano\n' + \ + f'{mail2news.__description__}') parser.add_argument('-H', '--smtpserver', default='') parser.add_argument('-s', '--sender', required=True, default='') @@ -232,12 +234,14 @@ def main(args_in=None): # check if n2m has some file prefercences set on commandline if args.wlfile is None: - wl = os.path.expanduser(os.path.join(os.path.dirname(__file__), 'pyg.whitelist')) + wl = os.path.expanduser(os.path.join(os.path.dirname(__file__), + 'pyg.whitelist')) else: wl = args.wlfile if args.logfile is None: - log = os.path.expanduser(os.path.join(os.path.dirname(__file__), 'pyg.log')) + log = os.path.expanduser(os.path.join(os.path.dirname(__file__), + 'pyg.log')) else: log = args.logfile @@ -251,7 +255,8 @@ def main(args_in=None): owner = wl.checkfrom(n2m.message['From']) if owner is None: if sys.stdin.isatty() == 1 or args.test: - out += str('"%s" is not in whitelist!' % (n2m.message['From'][:-1])) + '\n' + out += str('"%s" is not in whitelist!' % + (n2m.message['From'][:-1])) + '\n' else: wl.logmsg(n2m.nntpheads, wl.DENY) |