20 lines
619 B
Python
20 lines
619 B
Python
import os, configparser
|
|
|
|
preset_dir = 'print_config/presets/creality/base'
|
|
presets = []
|
|
for f in os.listdir(preset_dir):
|
|
if f.endswith('.inst.cfg'):
|
|
config = configparser.ConfigParser()
|
|
config.read(os.path.join(preset_dir, f))
|
|
try:
|
|
name = config.get('general', 'name', fallback=f)
|
|
except:
|
|
name = f.replace('.inst.cfg', '').replace('base_', '').replace('_', ' ')
|
|
presets.append((f, name))
|
|
|
|
presets = sorted(presets, key=lambda x: str(x[1]).lower())
|
|
print("Presets length:", len(presets))
|
|
if len(presets) > 0:
|
|
for p in presets[:5]:
|
|
print(p)
|