Created
October 12, 2016 22:23
-
-
Save dzfranklin/b975013a1b274764280c16730937e582 to your computer and use it in GitHub Desktop.
When given a css spreadsheet, finds the highest z index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
""" Analyze a css stylesheet to find the highest z index possible | |
Usage: ./max_z_index.py [filename] | |
To run on every file with .css in a directory, use `for f in $(ls); do echo $f | grep .css | xargs ./max_z_index.py; done` | |
""" | |
import fileinput | |
import re | |
def find_max_z(css_text): | |
matches = re.findall(r"z-index:([0-9]+)", css_text) | |
if matches: | |
return int(max(matches)) | |
else: | |
return 0 | |
if __name__ == "__main__": | |
css_text = "" | |
for line in fileinput.input(): | |
css_text += line | |
print(find_max_z(css_text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment