1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-18 09:57:40 +03:00

made all regexps raw strings

ensures no weirdness from escapes
This commit is contained in:
A_D 2020-07-19 16:41:22 +02:00 committed by Athanasius
parent ba67db3f13
commit a9f4f5d507

View File

@ -130,7 +130,7 @@ class EDLogs(FileSystemEventHandler):
# Latest pre-existing logfile - e.g. if E:D is already running. Assumes logs sort alphabetically. # Latest pre-existing logfile - e.g. if E:D is already running. Assumes logs sort alphabetically.
# Do this before setting up the observer in case the journal directory has gone away # Do this before setting up the observer in case the journal directory has gone away
try: try:
logfiles = sorted([x for x in listdir(self.currentdir) if re.search('^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', x)], logfiles = sorted([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:]) key=lambda x: x.split('.')[1:])
self.logfile = logfiles and join(self.currentdir, logfiles[-1]) or None self.logfile = logfiles and join(self.currentdir, logfiles[-1]) or None
except: except:
@ -189,7 +189,7 @@ class EDLogs(FileSystemEventHandler):
def on_created(self, event): def on_created(self, event):
# watchdog callback, e.g. client (re)started. # watchdog callback, e.g. client (re)started.
if not event.is_directory and re.search('^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', basename(event.src_path)): if not event.is_directory and re.search(r'^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', basename(event.src_path)):
self.logfile = event.src_path self.logfile = event.src_path
def worker(self): def worker(self):
@ -249,7 +249,7 @@ class EDLogs(FileSystemEventHandler):
else: else:
# Poll # Poll
try: try:
logfiles = sorted([x for x in listdir(self.currentdir) if re.search('^Journal(Beta)?\.[0-9]{12}\.[0-9]{2}\.log$', x)], logfiles = sorted([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:]) key=lambda x: x.split('.')[1:])
newlogfile = logfiles and join(self.currentdir, logfiles[-1]) or None newlogfile = logfiles and join(self.currentdir, logfiles[-1]) or None
except: except:
@ -761,7 +761,7 @@ class EDLogs(FileSystemEventHandler):
return return
ship = ship_file_name(self.state['ShipName'], self.state['ShipType']) ship = ship_file_name(self.state['ShipName'], self.state['ShipType'])
regexp = re.compile(re.escape(ship) + '\.\d\d\d\d\-\d\d\-\d\dT\d\d\.\d\d\.\d\d\.txt') 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: if oldfiles:
with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h: with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h: