move profile JSON files into subdirectory
s-ol
10 months ago
4 | 4 | from colorsys import hsv_to_rgb |
5 | 5 | import displayio |
6 | 6 | import json |
7 | import os | |
7 | 8 | |
8 | 9 | from .util import FONT_10, led_map |
9 | 10 | from .core import Mode, Key |
220 | 221 | order.append(id) |
221 | 222 | |
222 | 223 | try: |
223 | with open(f'profile{i}.hex.json', 'r') as f: | |
224 | with open(f'profiles/hex33board_{i}.json', 'r') as f: | |
224 | 225 | print(f"loading profile{i}") |
225 | 226 | data = json.load(f) |
226 | 227 | for id in order: |
251 | 252 | data[id] = self.settings[id].value |
252 | 253 | |
253 | 254 | try: |
254 | with open(f'profile{i}.hex.json', 'w') as f: | |
255 | try: | |
256 | os.mkdir('profiles') | |
257 | except OSError: | |
258 | pass | |
259 | ||
260 | with open(f'profiles/hex33board_{i}.json', 'w') as f: | |
255 | 261 | print(f"storing profile{i}") |
256 | 262 | json.dump(data, f) |
257 | 263 | except OSError as e: |