chiark / gitweb /
css: make postprocess.py work on Python < 3.6.
authorVladimír Vondruš <mosra@centrum.cz>
Sun, 17 Jun 2018 11:01:53 +0000 (13:01 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Sun, 17 Jun 2018 11:17:46 +0000 (13:17 +0200)
css/postprocess.py

index f18c27efa353c6b25aa4ccfea85bc10b7c2d192c..3cc9aa793769ea73c08aa69beefd133495b3eef6 100755 (executable)
@@ -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