42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import json
|
|
import os
|
|
|
|
# Define the path to the color palette seed file
|
|
color_palette_file_path = os.path.join('var', 'color_palette.json')
|
|
|
|
# Load color palette from the seed file
|
|
with open(color_palette_file_path, 'r') as color_palette_file:
|
|
color_palette = json.load(color_palette_file)
|
|
|
|
# Load your theme JSON structure
|
|
theme_template = {
|
|
"name": "Your Theme Name",
|
|
"colors": {
|
|
"editor.background": "${editorBackground}",
|
|
# ... add all other color placeholders
|
|
},
|
|
"tokenColors": [
|
|
{
|
|
"scope": ["comment", "punctuation.definition.comment", "string.comment"],
|
|
"settings": {
|
|
"foreground": "${commentForeground}"
|
|
}
|
|
},
|
|
# ... add all other token color placeholders
|
|
]
|
|
}
|
|
|
|
# Function to replace placeholders with actual color values
|
|
def replace_placeholders(template, palette):
|
|
json_str = json.dumps(template)
|
|
for key, value in palette.items():
|
|
placeholder = "${" + key + "}"
|
|
json_str = json_str.replace(placeholder, value)
|
|
return json.loads(json_str)
|
|
|
|
# Replace the placeholders in the template
|
|
final_theme = replace_placeholders(theme_template, color_palette)
|
|
|
|
# Write the final theme to a file
|
|
with open('your-theme-name-color-theme.json', 'w') as theme_file:
|
|
json.dump(final_theme, theme_file, indent=4) |