Created
April 29, 2015 11:55
-
-
Save jedie/379c25305185183da0b8 to your computer and use it in GitHub Desktop.
list all CSS lines with color values
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
import re | |
txt = open("/path/to/foobar.css,"r").read() | |
txt = re.sub("/\*.*?\*/(?s)", "", txt) # remove /* multi line */ comments | |
txt = re.sub("//.*?(?m)", "", txt) # remove // single line comments | |
regex = re.compile( | |
r""" | |
(?P<name>.*?) | |
\{ | |
(?P<data>.*?) | |
\}""", | |
re.IGNORECASE | re.VERBOSE | re.UNICODE | |
) | |
for match in regex.finditer(txt): | |
css_data = match.group("data") | |
if not "color" in css_data: | |
continue | |
print("%s {" % match.group("name")) | |
for part in css_data.split(";"): | |
if "color" in part: | |
print("\t%s;" % part) | |
print("}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment