Invert values of colour in CSS
<p>I have a CSS file where there are colours defined for certain elements. I want to invert the colours of these elements using some Python script. The format of colours are</p>

<ul>
<li>#XXX; or #XXX followed by space</li>
<li>#XXXXXX; or #XXXXXX followed by space</li>
</ul>

<p>I am able to grab the pattern using following regex expression:
 (\#)([a-fA-F0-9]*)(\;\w)</p>

<p>The problem is I am not able to figure out how to use it. I tried sed but it doesn't allow expression evaluation.</p>

<p>I may be wrong in assessment of my initial requirement.
Any help will be appreciated.</p>

<p>I have some pretty basic code that can invert hex.</p>

<pre><code># function takes in a hex color and outputs it inverted
def invert(color_to_convert): 
    table = string.maketrans('0123456789abcdef', 'fedcba9876543210')
    return '#' + color_to_convert[1:].lower().translate(table).upper()
</code></pre>

<p>Because to invert the chars just need to be turned around you can easily you need to switch zeros to f's and f's to zeros.</p>

python css