Skip to content

Commit

Permalink
Minor refactor, only write out file if it changed
Browse files Browse the repository at this point in the history
  • Loading branch information
julianneswinoga committed Feb 22, 2025
1 parent 581c921 commit e492dca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions OATFWGUI/gui_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ def patch_line(in_str: str) -> str:
patch_line(line)
for line in ini_lines
]
with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp:
fp.writelines(ini_lines)

if self.logic_state.env_is_avr_based():
# hard match the entire line
Expand All @@ -279,8 +277,6 @@ def patch_line(in_str: str) -> str:
good_platform_line if line == bad_platform_line else line
for line in ini_lines
]
with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp:
fp.writelines(ini_lines)

bad_ssd_1306_revision_re = re.compile(r'(ClutchplateDude/esp8266-oled-ssd1306\s*#\s*4\.6\.0)')
if any(bad_ssd_1306_revision_re.search(ini_line) for ini_line in ini_lines):
Expand All @@ -296,8 +292,14 @@ def patch_line(in_str: str) -> str:
patch_line(line)
for line in ini_lines
]

# Just re-read the ini file to see if we changed anything
if ini_lines != read_platformio_ini_file(self.logic_state):
log.debug('Writing out patched ini file')
with open(Path(self.logic_state.fw_dir, 'platformio.ini').resolve(), 'w') as fp:
fp.writelines(ini_lines)
else:
log.debug('No patches applied')

def build_fw(self):
self.main_app.wSpn_build.setState(BusyIndicatorState.BUSY)
Expand Down

0 comments on commit e492dca

Please sign in to comment.