From 05e6d498801c49dd64c451f13d4af25b71a97802 Mon Sep 17 00:00:00 2001 From: A_D Date: Sun, 19 Jul 2020 18:33:30 +0200 Subject: [PATCH] replaced list comp with generator where possible --- monitor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/monitor.py b/monitor.py index 90de7ad6..186c1ea5 100644 --- a/monitor.py +++ b/monitor.py @@ -132,7 +132,7 @@ class EDLogs(FileSystemEventHandler): # Do this before setting up the observer in case the journal directory has gone away try: logfiles = sorted( - [x for x in listdir(self.currentdir) if re.search(r'^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', x)], + (x for x in listdir(self.currentdir) if re.search(r'^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', x)), key=lambda x: x.split('.')[1:] ) @@ -282,8 +282,8 @@ class EDLogs(FileSystemEventHandler): # Poll try: logfiles = sorted( - [x for x in listdir(self.currentdir) if - re.search(r'^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', x)], + (x for x in listdir(self.currentdir) if + re.search(r'^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', x)), key=lambda x: x.split('.')[1:] ) @@ -890,7 +890,7 @@ class EDLogs(FileSystemEventHandler): ship = ship_file_name(self.state['ShipName'], self.state['ShipType']) regexp = re.compile(re.escape(ship) + r'\.\d{4}\-\d\d\-\d\dT\d\d\.\d\d\.\d\d\.txt') - oldfiles = sorted([x for x in listdir(config.get('outdir')) if regexp.match(x)]) + oldfiles = sorted((x for x in listdir(config.get('outdir')) if regexp.match(x))) if oldfiles: with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h: if h.read() == string: