in colorSchemeTool.py [0:0]
def write_idea_scheme(filename):
name, ext = os.path.splitext(os.path.basename(filename))
baseName = "Darcula" if isDark() else "Default"
scheme = ET.Element("scheme", name=underscore_to_camelcase(name), version="1", parent_scheme=baseName)
colors = ET.SubElement(scheme, 'colors')
for name, value in all_colors.items():
ET.SubElement(colors, 'option', name=name, value=value)
attributes = ET.SubElement(scheme, 'attributes')
# let's sort attributes, then diffs between generated schemes will look nice
all_attributes.sort(key=lambda attr: attr.id)
for attr in all_attributes:
if attr.value.inherited:
print('inheriting ' + attr.id + ' from ' + attr.parent.id)
elif isinstance(attr.value, DerivedAttributeValue):
print('transforming IDEA default color for ' + attr.id)
fore = attr.value.foreground
back = attr.value.background
saveFg = fore and (fore != IGNORE_COLOR_VALUE)
saveBg = back and (back != IGNORE_COLOR_VALUE)
if saveFg or saveBg or attr.value.font_style or attr.value.effect_type or attr.value.error_stripe:
option = ET.SubElement(attributes, 'option', name=attr.id)
value = ET.SubElement(option, 'value')
if saveFg: ET.SubElement(value, 'option', name='FOREGROUND', value=fore)
if saveBg: ET.SubElement(value, 'option', name='BACKGROUND', value=back)
if attr.value.font_style:
ET.SubElement(value, 'option', name='FONT_TYPE', value=str(attr.value.font_style))
if attr.value.effect_type:
ET.SubElement(value, 'option', name='EFFECT_TYPE', value=str(attr.value.effect_type))
if attr.value.effect_color:
ET.SubElement(value, 'option', name='EFFECT_COLOR', value=attr.value.effect_color)
elif fore:
ET.SubElement(value, 'option', name='EFFECT_COLOR', value=fore)
else:
ET.SubElement(value, 'option', name='EFFECT_COLOR', value=text.value.foreground)
if attr.value.error_stripe:
ET.SubElement(value, 'option', name='ERROR_STRIPE_COLOR', value=attr.value.error_stripe)
else:
ET.SubElement(attributes, 'option', name=attr.id, baseAttributes=attr.parent.id)
indent(scheme)
capitalize_colors(scheme)
tree = ET.ElementTree(scheme)
removeNoneAttrib(tree.getroot())
tree.write(filename)