1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 15:57:14 +03:00

Tidied regexp

Python regexps should always be held in r'' or raw strings, ensuring
that python doesn't try to expand the regexp escapes.

I also removed the escaped -, as they're only special characters in
character groups
This commit is contained in:
A_D 2020-07-10 05:49:21 +02:00
parent be9ac29a5b
commit a6e6b6353d
No known key found for this signature in database
GPG Key ID: 4BE9EB7DF45076C4

View File

@ -200,7 +200,7 @@ def export(data, filename=None):
# Look for last ship of this type
ship = companion.ship_file_name(data['ship'].get('shipName'), data['ship']['name'])
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 os.listdir(config.get('outdir')) if regexp.match(x)])
if oldfiles:
with open(join(config.get('outdir'), oldfiles[-1]), 'rU') as h: