From 91d5b00c555026ecd3e28b9419c634d01ddb0e99 Mon Sep 17 00:00:00 2001 From: Murali Manohar Varma Pemmadi Date: Fri, 31 Oct 2025 06:32:06 +0530 Subject: [PATCH] fix: improve file path handling in theme generator script (#9426) - Use Path objects from pathlib to handle file paths properly - Generate output files in the same directory as input file - Create output filenames with "new_" prefix while preserving original stem name - Ensure script works with files from any location in the filesystem --- scripts/themes/create_blockStyles.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/themes/create_blockStyles.py b/scripts/themes/create_blockStyles.py index d1f88a4b0..2b9b2bb16 100644 --- a/scripts/themes/create_blockStyles.py +++ b/scripts/themes/create_blockStyles.py @@ -154,12 +154,15 @@ def findRgbVal(colour): # Get info on the input file def getFileInfo(): + from pathlib import Path if (len(sys.argv) < 2): print("Please provide a filename") sys.exit() fileName = sys.argv[1] try: jsonFile = open(fileName).read() + fileName = str(Path(fileName).parent / f"new_{Path(fileName).stem}.json") + fileName = Path(fileName) except IOError as err: print('Could not find that file name') sys.exit() @@ -174,7 +177,7 @@ def createColourMap(): for key in jsonData.keys(): rgbVal = findRgbVal(jsonData[key]) colourObj[key] = findOtherColours(rgbVal) - f= open("new_" + fileName,"w+") + f= open(fileName,"w+") f.write(json.dumps(colourObj, indent=2, sort_keys=True)) f.close()