Skip to content

Commit

Permalink
[Added] Stronger workaround for people using backslashes in WKSs
Browse files Browse the repository at this point in the history
Should cover all the cases where we read the WKSs from the project

See #719 and #607
  • Loading branch information
set-soft committed Nov 14, 2024
1 parent 0ae3b4d commit 0c82347
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.8.3] - UNRELEASED
### Added
- Workaround for people using backslashes (i.e. Windows+WSL) (#719) (#607)
More general than in previous versions.
- Global options:
- `work_layer`: to choose the temporal layer for internal operations (#713)
- BoM:
Expand Down
7 changes: 7 additions & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Versioning <https://semver.org/spec/v2.0.0.html>`__.
Added
~~~~~

- Workaround for people using backslashes (i.e. Windows+WSL) (#719)
(#607) More general than in previous versions.
- Global options:

- ``work_layer``: to choose the temporal layer for internal
Expand All @@ -43,6 +45,11 @@ Added
- ``use_ref_ranges`` alias for ``use_alt``
- New *kicad* format to mimic KiCad’s internal BoM.

- Drill:

- Option to don’t generate the drill files, so you can generate only
the maps (#720)

- PCB Print: a mechanism to filter components for a particular layer
(#706)
- SCH Variant and \*SCH Print:
Expand Down
17 changes: 13 additions & 4 deletions kibot/kicad/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ def parse_len_str(val):
return value


def fix_windows(name):
if not os.path.isfile(name):
fixed = name.replace('\\', '/')
if os.path.isfile(fixed):
logger.debug(f'Fixing windows path: {name} -> {fixed}')
return fixed
return name


def expand_env(val, env, extra_env, used_extra=None):
""" Expand KiCad environment variables """
if used_extra is None:
Expand Down Expand Up @@ -630,7 +639,7 @@ def fix_page_layout_k6_key(key, data, dest_dir, forced):
section = data[key]
pl = section.get('page_layout_descr_file', None) if not forced else forced
if pl:
fname = KiConf.expand_env(pl)
fname = fix_windows(KiConf.expand_env(pl))
if os.path.isfile(fname):
dest = os.path.join(dest_dir, key+'.kicad_wks')
logger.debug('Copying {} -> {}'.format(fname, dest))
Expand Down Expand Up @@ -658,10 +667,10 @@ def fix_page_layout_k6(project, dry, force_sch, force_pcb):
else:
aux = data.get('schematic', None)
if aux:
layouts[0] = KiConf.expand_env(aux.get('page_layout_descr_file', None), ref_dir=dest_dir)
layouts[0] = fix_windows(KiConf.expand_env(aux.get('page_layout_descr_file', None), ref_dir=dest_dir))
aux = data.get('pcbnew', None)
if aux:
layouts[1] = KiConf.expand_env(aux.get('page_layout_descr_file', None), ref_dir=dest_dir)
layouts[1] = fix_windows(KiConf.expand_env(aux.get('page_layout_descr_file', None), ref_dir=dest_dir))
return layouts

def fix_page_layout_k5(project, dry, force_sch, force_pcb):
Expand All @@ -683,7 +692,7 @@ def fix_page_layout_k5(project, dry, force_sch, force_pcb):
elif force_pcb and is_pcb_new:
dest = force_pcb
elif fname:
fname = KiConf.expand_env(fname)
fname = fix_windows(KiConf.expand_env(fname))
if os.path.isfile(fname):
dest = os.path.join(dest_dir, str(order)+'.kicad_wks')
if not dry:
Expand Down
6 changes: 1 addition & 5 deletions kibot/out_any_sch_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ def run(self, name):
else:
ori_wks = new_wks = wks[0]
if ori_wks and not os.path.isfile(new_wks):
# Try replacing backslashes
try_wks = new_wks.replace('\\', '/')
if not os.path.isfile(try_wks):
raise KiPlotConfigurationError(f'Missing `{new_wks}` worksheet')
new_wks = try_wks
raise KiPlotConfigurationError(f'Missing `{new_wks}` worksheet')
if ori_wks != new_wks:
prj = GS.read_pro()
GS.fix_page_layout(GS.pro_file, dry=False, force_sch=os.path.relpath(new_wks, GS.pro_dir),
Expand Down

0 comments on commit 0c82347

Please sign in to comment.