Skip to content

Commit

Permalink
[Fixed] Project files are now restored using binary mode.
Browse files Browse the repository at this point in the history
- So we preserve the original end of line.

Related to INTI-CMNB/KiBot#265
  • Loading branch information
set-soft committed Sep 2, 2022
1 parent c406045 commit 39c0529
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions kiauto/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ 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:
cfg.prl_name = name_no_ext+'.'+cfg.prl_ext
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()


Expand All @@ -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))

Expand Down

0 comments on commit 39c0529

Please sign in to comment.