From 39c052980248e22fb0afdb993b0e48515bfdf6af Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 2 Sep 2022 09:23:27 -0300 Subject: [PATCH] [Fixed] Project files are now restored using binary mode. - So we preserve the original end of line. Related to INTI-CMNB/KiBot#265 --- CHANGELOG.md | 6 ++++++ kiauto/file_util.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ebff2b..e9c31e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for the asynchronous "Info" dialogs found in KiCad 6. Example: missing .kicad_wks (See INTI-CMNB/KiBot#264) +### Fixed +- Project files are now restored using binary mode. So we preserve the + original end of line. + + ## [2.0.2] - 2022-08-26 ### Fixed - Problems when the output directory doesn't exist. + ## [2.0.1] - 2022-08-22 ### Added - Support for the error dialog we get when sub-sheets are missing. diff --git a/kiauto/file_util.py b/kiauto/file_util.py index 21bc1aa..21d189f 100644 --- a/kiauto/file_util.py +++ b/kiauto/file_util.py @@ -317,7 +317,7 @@ def memorize_project(cfg): cfg.pro_stat = cfg.start_pro_stat else: cfg.pro_stat = cfg.start_kicad_pro_stat - with open(cfg.pro_name) as f: + with open(cfg.pro_name, 'rb') as f: cfg.pro_content = f.read() atexit.register(restore_project, cfg) if cfg.prl_ext: @@ -325,7 +325,7 @@ def memorize_project(cfg): if not os.path.isfile(cfg.prl_name): return cfg.prl_stat = cfg.start_kicad_prl_stat - with open(cfg.prl_name) as f: + with open(cfg.prl_name, 'rb') as f: cfg.prl_content = f.read() @@ -341,7 +341,7 @@ def _restore_project(name, stat_v, content): if not pro_found or new_stat.st_mtime != stat_v.st_mtime: logger.debug('Restoring the project file') os.rename(name, name+'-bak') - with open(name, 'wt') as f: + with open(name, 'wb') as f: f.write(content) os.utime(name, times=(stat_v.st_atime, stat_v.st_mtime))