From: Vladimír Vondruš Date: Sun, 17 Jun 2018 11:01:53 +0000 (+0200) Subject: css: make postprocess.py work on Python < 3.6. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=073e07d606443f5e0b8acb536bdc8b632d5b576b;p=blog.git css: make postprocess.py work on Python < 3.6. --- diff --git a/css/postprocess.py b/css/postprocess.py index f18c27ef..3cc9aa79 100755 --- a/css/postprocess.py +++ b/css/postprocess.py @@ -64,20 +64,20 @@ def postprocess(files, process_imports, out_file): match = import_rx.match(line) if match: if process_imports: - imported_files += [match['file']] + imported_files += [match.group('file')] continue # Variable use, replace with actual value # TODO: more variables on the same line? match = variable_use_rx.match(line) - if match and match['key'] in variables: - out.write(match['before']) - out.write(variables[match['key']]) + if match and match.group('key') in variables: + out.write(match.group('before')) + out.write(variables[match.group('key')]) # Strip the trailing comment, if there, to save some bytes - if match['after'].endswith('*/'): - out.write(match['after'][:match['after'].rindex('/*')].rstrip()) + if match.group('after').endswith('*/'): + out.write(match.group('after')[:match.group('after').rindex('/*')].rstrip()) else: - out.write(match['after']) + out.write(match.group('after')) out.write("\n") continue @@ -90,7 +90,7 @@ def postprocess(files, process_imports, out_file): # Variable declaration match = variable_declaration_rx.match(line) if match and in_variable_declarations: - variables[match['key']] = match['value'] + variables[match.group('key')] = match.group('value') continue # Comment or empty line, ignore