Skip to content

Commit 72302ab

Browse files
committed
[Copy Files][Added] Now dest also expands %X patterns
- Can be disabled using `expand_dest` See #873
1 parent be154e2 commit 72302ab

7 files changed

Lines changed: 38 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2929
- PCB Print: Workaround for KiCad 9.0.5 change in how holes are plotted when
3030
a layer is not included (black instead of white).
3131
- Export_3D: `center` option to `origin` (#871)
32-
- Compress: Now `dest` also expands %X patterns (can be disabled) (#873)
32+
- Compress/Copy Files: Now `dest` also expands %X patterns (can be disabled)
33+
(#873)
3334

3435
### Fixed
3536
- User.N layer numbering. I.e. pcb_print issues with their numbering (#808)

docs/samples/generic_plot.kibot.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,8 @@ outputs:
935935
# Can be used to fine-tune a variant for a particular output that needs extra filtering done before the
936936
# variant
937937
exclude_filter: '_null'
938+
# [boolean=true] Also expand the `dest` file name (using % patterns)
939+
expand_dest: true
938940
# [list(dict)=[]] Which files will be included
939941
files:
940942
# [string=''] Destination directory inside the output dir, empty means the same of the file

docs/source/Changelog.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Added
5353
- PCB Print: Workaround for KiCad 9.0.5 change in how holes are plotted
5454
when a layer is not included (black instead of white).
5555
- Export_3D: ``center`` option to ``origin`` (#871)
56-
- Compress: Now ``dest`` also expands %X patterns (can be disabled)
57-
(#873)
56+
- Compress/Copy Files: Now ``dest`` also expands %X patterns (can be
57+
disabled) (#873)
5858

5959
Fixed
6060
~~~~~

docs/source/configuration/outputs/Copy_FilesOptions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Copy_FilesOptions parameters
2525
Can be used to fine-tune a variant for a particular output that needs extra filtering done before the
2626
variant.
2727

28+
- ``expand_dest`` :index:`: <pair: output - copy_files - options; expand_dest>` [:ref:`boolean <boolean>`] (default: ``true``) Also expand the `dest` file name (using % patterns).
2829
- ``follow_links`` :index:`: <pair: output - copy_files - options; follow_links>` [:ref:`boolean <boolean>`] (default: ``true``) Store the file pointed by symlinks, not the symlink.
2930
- ``kicad_3d_url`` :index:`: <pair: output - copy_files - options; kicad_3d_url>` [:ref:`string <string>`] (default: ``'https://gitlab.com/kicad/libraries/kicad-packages3D/-/raw/master/'``) Base URL for the KiCad 3D models.
3031
- ``kicad_3d_url_suffix`` :index:`: <pair: output - copy_files - options; kicad_3d_url_suffix>` [:ref:`string <string>`] (default: ``''``) Text added to the end of the download URL.

kibot/out_copy_files.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def __init__(self):
9292
""" Store the file pointed by symlinks, not the symlink """
9393
self.link_no_copy = False
9494
""" Create symlinks instead of copying files """
95+
self.expand_dest = True
96+
""" Also expand the `dest` file name (using % patterns) """
9597
super().__init__()
9698
self._expand_id = 'copy'
9799
self._expand_ext = 'files'
@@ -202,12 +204,13 @@ def get_3d_models(self, f, mode_project, dry):
202204
extra_files = []
203205
GS.check_pcb()
204206
GS.load_board()
207+
dest_exp = f.expand_filename_both(f.dest, make_safe=False) if self.expand_dest else f.dest
205208
if mode_project:
206209
# From the PCB point this is just the 3D models dir
207210
f.output_dir = '3d_models'
208211
f._append_mode = True
209212
else:
210-
dest_dir = f.dest
213+
dest_dir = dest_exp
211214
f._append_mode = False
212215
if dest_dir and dest_dir[-1] == '+':
213216
dest_dir = dest_dir[:-1]
@@ -222,7 +225,7 @@ def get_3d_models(self, f, mode_project, dry):
222225
if f.save_pcb or mode_project:
223226
dest_dir = self.output_dir
224227
if mode_project:
225-
dest_dir = os.path.join(dest_dir, f.dest)
228+
dest_dir = os.path.join(dest_dir, dest_exp)
226229
os.makedirs(dest_dir, exist_ok=True)
227230
fname = os.path.join(dest_dir, os.path.basename(GS.pcb_file))
228231
if not dry:
@@ -256,8 +259,8 @@ def get_3d_models(self, f, mode_project, dry):
256259
if wks[1] and not wks[1].startswith(EMBED_PREFIX): # PCB WKS
257260
extra_files.append(os.path.join(os.path.dirname(prj_name), 'pcbnew.kicad_wks'))
258261
if mode_project:
259-
extra_files += self.copy_footprints(f.dest, dry)
260-
extra_files += self.copy_symbols(f.dest, dry)
262+
extra_files += self.copy_footprints(dest_exp, dry)
263+
extra_files += self.copy_symbols(dest_exp, dry)
261264
if not self._comps:
262265
# We must undo the download/rename
263266
self.undo_3d_models_rename(GS.board)
@@ -276,7 +279,7 @@ def get_3d_models(self, f, mode_project, dry):
276279
new_list.append(fn)
277280
if mode_project:
278281
# From the output point this needs to add the destination dir
279-
f.output_dir = os.path.join(f.dest, f.output_dir)
282+
f.output_dir = os.path.join(dest_exp, f.output_dir)
280283
return files_list+fnmatch.filter(new_list, f.source), extra_files
281284

282285
def get_files(self, no_out_run=False):
@@ -326,7 +329,8 @@ def get_files(self, no_out_run=False):
326329
if f.dest and not f._append_mode:
327330
# A destination specified by the user
328331
# All files goes to the same destination directory
329-
dest = os.path.join(f.dest, os.path.basename(fname))
332+
dest_exp = f.expand_filename_both(f.dest, make_safe=False) if self.expand_dest else f.dest
333+
dest = os.path.join(dest_exp, os.path.basename(fname))
330334
elif (mode_3d or mode_project) and is_abs:
331335
for d in self.rel_dirs:
332336
if d is not None and fname.startswith(d):

tests/GUI/outputs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,6 +2124,13 @@
21242124
],
21252125
null
21262126
],
2127+
[
2128+
"expand_dest",
2129+
[
2130+
"DataTypeBoolean"
2131+
],
2132+
null
2133+
],
21272134
[
21282135
"no_virtual",
21292136
[

tests/GUI/stats

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
53 outputs types with a total of 2129 different parameters
2-
Single type parameters: 1943 (91 %)
1+
53 outputs types with a total of 2130 different parameters
2+
Single type parameters: 1944 (91 %)
33
Multi type parameters: 186 (9 %)
44
Average parameters: 40
55
Maximum number of parameters: 217
66
Minimum number of parameters: 14
77
Histogram:
88
0- 9:
99
10- 19: *****
10-
20- 29: ***********************
11-
30- 39: ********
10+
20- 29: **********************
11+
30- 39: *********
1212
40- 49: *********
1313
50- 59: **
1414
60- 69: **
@@ -55,7 +55,7 @@ Outputs sorted by parameters:
5555
- hpgl_sch_print: 27
5656
- kikit_present: 27
5757
- stencil_for_jig: 28
58-
- copy_files: 29
58+
- copy_files: 30
5959
- pdf_pcb_print: 31
6060
- position: 31
6161
- report: 33
@@ -148,7 +148,7 @@ Outputs sorted by depth:
148148
--------------------------------------------------------------------------------
149149
14 different data types
150150
- String: 924
151-
- Boolean: 537
151+
- Boolean: 538
152152
- Number: 290
153153
- ListStringSingular: 288
154154
- Choice: 110
@@ -164,7 +164,7 @@ Outputs sorted by depth:
164164
--------------------------------------------------------------------------------
165165
Used as single data type:
166166
- String: 760
167-
- Boolean: 472
167+
- Boolean: 473
168168
- ListStringSingular: 285
169169
- Number: 196
170170
- Choice: 107
@@ -403,17 +403,17 @@ Used as single data type:
403403
- Number,String: 15
404404
================================================================================
405405
================================================================================
406-
92 totals types with a total of 2508 different parameters
407-
Single type parameters: 2298 (92 %)
406+
92 totals types with a total of 2509 different parameters
407+
Single type parameters: 2299 (92 %)
408408
Multi type parameters: 210 (8 %)
409409
Average parameters: 27
410410
Maximum number of parameters: 217
411411
Minimum number of parameters: 1
412412
Histogram:
413413
0- 9: ************************
414414
10- 19: **************
415-
20- 29: ****************************
416-
30- 39: *********
415+
20- 29: ***************************
416+
30- 39: **********
417417
40- 49: *********
418418
50- 59: **
419419
60- 69: **
@@ -498,7 +498,7 @@ Totals sorted by parameters:
498498
- hpgl_sch_print: 27
499499
- kikit_present: 27
500500
- stencil_for_jig: 28
501-
- copy_files: 29
501+
- copy_files: 30
502502
- pdf_pcb_print: 31
503503
- position: 31
504504
- report: 33
@@ -631,7 +631,7 @@ Totals sorted by depth:
631631
--------------------------------------------------------------------------------
632632
14 different data types
633633
- String: 1080
634-
- Boolean: 637
634+
- Boolean: 638
635635
- Number: 340
636636
- ListStringSingular: 318
637637
- Choice: 142
@@ -647,7 +647,7 @@ Totals sorted by depth:
647647
--------------------------------------------------------------------------------
648648
Used as single data type:
649649
- String: 900
650-
- Boolean: 564
650+
- Boolean: 565
651651
- ListStringSingular: 315
652652
- Number: 231
653653
- Choice: 139

0 commit comments

Comments
 (0)