From 37647010d903872195bd378581cb3383c50585e3 Mon Sep 17 00:00:00 2001 From: sanjayk03-dev Date: Sun, 28 Jan 2024 02:05:41 +0530 Subject: [PATCH] trying with key --- src/py/bbctrl/Config.py | 28 ++++++++++++++-------------- src/resources/config-template.json | 3 +++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/py/bbctrl/Config.py b/src/py/bbctrl/Config.py index 7eae2ed..d0aedfb 100644 --- a/src/py/bbctrl/Config.py +++ b/src/py/bbctrl/Config.py @@ -130,14 +130,14 @@ class Config(object): config[name] = template['min'] if template['type'] == 'list': - if 'index' in template: - config = config[name] + # if 'index' in template: + config = config[name] - for i in range(len(template['index'])): - if len(config) <= i: config.append({}) + for i in range(len(template['index'])): + if len(config) <= i: config.append({}) - for name, tmpl in template['template'].items(): - self.__defaults(config[i], name, tmpl) + for name, tmpl in template['template'].items(): + self.__defaults(config[i], name, tmpl) else: for name, tmpl in template.items(): @@ -213,14 +213,14 @@ class Config(object): # Handle list if tmpl['type'] == 'list': - if 'index' in tmpl: - for i in range(len(tmpl['index'])): - if config is not None and i < len(config): conf = config[i] - else: conf = None - self._encode(name, index + tmpl['index'][i], conf, - tmpl['template'], with_defaults) - else: - self.values[name]=value; + # if 'index' in tmpl: + for i in range(len(tmpl['index'])): + if config is not None and i < len(config): conf = config[i] + else: conf = None + self._encode(name, index + tmpl['index'][i], conf, + tmpl['template'], with_defaults) + # else: + # self.values[name]=value; return # Update config values diff --git a/src/resources/config-template.json b/src/resources/config-template.json index 6df6752..e0125b6 100644 --- a/src/resources/config-template.json +++ b/src/resources/config-template.json @@ -535,6 +535,7 @@ "macros": { "type": "list", + "index": "12345678", "default": [ { "name": "Macros 1", @@ -595,6 +596,7 @@ "macrosList": { "type": "list", + "index": "0123456", "default": [], "template": { "file_name": { @@ -606,6 +608,7 @@ "gcodeList": { "type": "list", + "index": "012345", "default": [], "template": { "file_name": {