Skip to content

Commit

Permalink
Fix generate_theme.py not finding the fill color
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Apr 10, 2017
1 parent 3c98079 commit 2457ccc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions themes/generate_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import os
import subprocess

color_re = \
re.compile('<g\s+id="export_(\w+)"\s+style=".*?fill:#([0-9a-f]+)[\S\s]*?')
group_id_re = \
re.compile('<g[\S\s]+?id="export_(\w+)"[\S\s]+?>')

fill_re = \
re.compile('fill:#([0-9a-f]+)')

template = '''{{
"name": "{name}",
Expand Down Expand Up @@ -90,9 +93,14 @@ def work(filename):
xml = f.read().replace('\n', '')

replacements = {}
for m in color_re.finditer(xml):
for m in group_id_re.finditer(xml):
f = fill_re.search(m.group(0))
if not f:
raise ValueError(
'Error: The object %s missing the fill attribute' % m.group(1))

# Append 'ff' because the themes require the alpha to be set
replacements[m.group(1)] = m.group(2)+'ff'
replacements[m.group(1)] = f.group(1) + 'ff'

replacements['name'] = input('Enter theme name for "{}": '.format(name))
replacements['price'] = input('Enter theme price: ')
Expand Down

0 comments on commit 2457ccc

Please sign in to comment.