chore: Remove unused function _ensure_packages_have_version

This commit is contained in:
Mauro Balades 2024-08-25 12:51:30 +02:00
parent 079d43b32a
commit 4d6424f9ea
2 changed files with 5 additions and 9 deletions

View file

@ -1,6 +0,0 @@
def ensure_packages_have_version(theme_data):
if theme_data.get('version', None) is None:
print(" Version is required in theme.json. Adding default value of 1.0.0.")
theme_data['version'] = '1.0.0'
return theme_data

View file

@ -2,8 +2,6 @@
import os import os
import json import json
import _ensure_packages_have_version
THEMES_FOLDER = './themes' THEMES_FOLDER = './themes'
THEMES_DATA_FILE = './themes.json' THEMES_DATA_FILE = './themes.json'
@ -48,7 +46,6 @@ def main():
continue continue
with open(theme_data_file, 'r') as f: with open(theme_data_file, 'r') as f:
theme_data = json.load(f) theme_data = json.load(f)
theme_data = _ensure_packages_have_version.ensure_packages_have_version(theme_data)
with open(THEMES_DATA_FILE, 'r') as f: with open(THEMES_DATA_FILE, 'r') as f:
themes_data = json.load(f) themes_data = json.load(f)
theme_colors_file = os.path.join(theme_folder, 'colors.json') theme_colors_file = os.path.join(theme_folder, 'colors.json')
@ -59,7 +56,12 @@ def main():
if 'isDarkMode' in colors: if 'isDarkMode' in colors:
theme_data['isDarkMode'] = colors['isDarkMode'] theme_data['isDarkMode'] = colors['isDarkMode']
theme_data['isColorTheme'] = True theme_data['isColorTheme'] = True
past_version = None
if theme in themes_data:
past_version = themes_data[theme].get('version', None)
themes_data[theme] = theme_data themes_data[theme] = theme_data
if past_version is not None:
themes_data[theme]['version'] = past_version
with open(THEMES_DATA_FILE, 'w') as f: with open(THEMES_DATA_FILE, 'w') as f:
json.dump(themes_data, f, indent=4) json.dump(themes_data, f, indent=4)
print(f"Rebuilt theme: {theme}") print(f"Rebuilt theme: {theme}")