Files
AIO_3D_Print_Web_Platform/tmp/parse_presets.py

20 lines
719 B
Python

import os
import configparser
def get_quality_presets():
preset_dir = os.path.join(os.path.dirname(__file__), 'print_config', 'presets', 'creality', 'base')
presets = []
if os.path.exists(preset_dir):
for f in os.listdir(preset_dir):
if f.startswith('base_global_') and f.endswith('.inst.cfg'):
config = configparser.ConfigParser()
try:
config.read(os.path.join(preset_dir, f))
name = config.get('general', 'name', fallback=f)
presets.append((f, name))
except Exception as e:
pass
return sorted(presets, key=lambda x: x[1])
print(get_quality_presets())