Created
October 25, 2015 16:07
-
-
Save franksn/7c8404d6deb49ee9204c to your computer and use it in GitHub Desktop.
invert colors from css
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 | |
import Tkinter, tkFileDialog | |
root = Tkinter.Tk() | |
root.withdraw() | |
p6 = re.compile("#[0-9a-f]{6};", re.IGNORECASE) | |
p3 = re.compile("#[0-9a-f]{3};", re.IGNORECASE) | |
filepath = tkFileDialog.askopenfilename(title= "file?",) | |
content = file(filepath,'r').read() | |
def Modify (content): | |
text = content.group().lower() | |
code = {} | |
l1="#;0123456789abcdef" | |
l2="#;fedcba9876543210" | |
for i in range(len(l1)): | |
code[l1[i]]=l2[i] | |
inverted = "" | |
for j in text: | |
inverted += code[j] | |
return inverted | |
content = p6.sub(Modify,content) | |
content = p3.sub(Modify,content) | |
filepath = filepath[:-4]+"MOD.css" | |
out = file(filepath,'w') | |
out.write(content) | |
out.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment