python - 使用 python 保存不同的预设
问题描述
对于我的浓缩咖啡机,我正在使用 PyQt5 在 Python 中编写 GUI。我想保存不同的“配置文件”,我可以根据我使用的 bean 来回忆它们。有一个用 TCL 编写的固件(来自名为“不错的浓缩咖啡机”的机器),它显示了我想要的内容(我将附上 2 张图像和其中一个描述文件的片段,该文件中的第 1 行包含不同的步骤)。
我不确定我应该使用哪个解析器。我显然总是想为相同的参数保存不同的值(在 c 中我会说相同的结构),所以在某种程度上使用像 configparser 这样总是有独立部分的东西感觉不对。
有人可以给我一个提示我应该使用什么库。总是有相同的参数,但不同的配方可能包含不同数量的步骤。
我想要这样的伪代码:
recipe=open('recipe1.txt')
currentstep=0
for steps in recipe:
pressure = step[currentstep].pressure
flow = step[currentstep].flow
...
brew()
currentstep = currentstep + 1
这是在 TCL 文件中:
advanced_shot {{exit_if 1 flow 6.0 volume 100 transition fast exit_flow_under 0 temperature 90.0 name infuse pressure 1 sensor coffee pump flow exit_type pressure_over exit_flow_over 6 exit_pressure_over 3.0 exit_pressure_under 0 seconds 20.0} {exit_if 0 volume 100 transition fast exit_flow_under 0 temperature 90.0 name {rise and hold} pressure 9.0 sensor coffee pump pressure exit_flow_over 6 exit_pressure_over 11 seconds 10.0 exit_pressure_under 0} {exit_if 1 volume 100 transition smooth exit_flow_under 0 temperature 90.0 name decline pressure 4.0 sensor coffee pump pressure exit_type pressure_under exit_flow_over 1.2 exit_pressure_over 11 seconds 20.0 exit_pressure_under 4.0} {exit_if 1 flow 1.2 volume 100 transition smooth exit_flow_under 0 temperature 90.0 name {pressure limit} pressure 4.0 sensor coffee pump pressure exit_type flow_over exit_flow_over 1.0 exit_pressure_over 11 exit_pressure_under 0 seconds 10.0} {exit_if 0 flow 1.0 volume 100 transition smooth exit_flow_under 0 temperature 90.0 name {flow limit} pressure 3.0 sensor coffee pump flow exit_flow_over 6 exit_pressure_over 11 seconds 30.0 exit_pressure_under 0}}
author Decent
beverage_type espresso
espresso_decline_time 30
espresso_hold_time 15
espresso_pressure 6.0
espresso_temperature 90.0
final_desired_shot_volume 32
final_desired_shot_volume_advanced 0
final_desired_shot_weight 32
final_desired_shot_weight_advanced 36
flow_profile_decline 1.2
flow_profile_decline_time 17
flow_profile_hold 2
flow_profile_hold_time 8
flow_profile_minimum_pressure 4
flow_profile_preinfusion 4
flow_profile_preinfusion_time 5
preinfusion_flow_rate 4
preinfusion_guarantee 1
preinfusion_stop_pressure 4.0
preinfusion_time 20
pressure_end 4.0
profile_hide 0
profile_language en
profile_notes {An advanced spring lever profile by John Weiss that addresses a problem with simple spring lever profiles, by using both pressure and flow control. The last two steps keep pressure/flow under control as the puck erodes, if the shot has not finished by the end of step 3. Please consider this as a starting point for tweaking.}
profile_title {Advanced spring lever}
settings_profile_type settings_2c
tank_desired_water_temperature 0
water_temperature 80
解决方案
推荐阅读
- preload - 预加载响应式图像
- php - PayPal Plus - 确认付款状态
- javascript - 为变量赋值 - 简化现有代码
- macos - 如何解决 NSCollectionViewItem 重叠问题?
- java - kotlinOptions.jvmTarget 与 Gradle 变体冲突
- python - 如何访问活动警告过滤器列表?
- javascript - 在表行悬停时调用函数
- windows-services - 使用.net core 3.1中的设置文件,单文件发布windows服务
- python - 当且仅当图保持连接时从nx图中删除节点?
- mysql - 我有一个问题 BCRYPT 与 NodeJs 比较比较 Mysql 数据库中的密码