Skip to content

Commit 92eb40b

Browse files
committed
[Compress][Added] Now dest also expands %X patterns
- Can be disabled using `expand_dest` Closes #873
1 parent e27f8c1 commit 92eb40b

7 files changed

Lines changed: 27 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ 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)
3233

3334
### Fixed
3435
- 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
@@ -874,6 +874,8 @@ outputs:
874874
options:
875875
# [string='auto'] [auto,stored,deflated,bzip2,lzma] Compression algorithm. Use auto to let KiBot select a suitable one
876876
compression: 'auto'
877+
# [boolean=true] Also expand the `dest` file name (using % patterns)
878+
expand_dest: true
877879
# [list(dict)=[]] Which files will be included
878880
files:
879881
# [string=''] Destination directory inside the archive, empty means the same of the file

docs/source/Changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +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)
5658

5759
Fixed
5860
~~~~~

docs/source/configuration/outputs/CompressOptions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CompressOptions parameters
88
- **format** :index:`: <pair: output - compress - options; format>` [:ref:`string <string>`] (default: ``'ZIP'``) (choices: "ZIP", "TAR", "RAR") Output file format.
99
- **output** :index:`: <pair: output - compress - options; output>` [:ref:`string <string>`] (default: ``'%f-%i%I%v.%x'``) Name for the generated archive (%i=name of the output %x=according to format). Affected by global options.
1010
- ``compression`` :index:`: <pair: output - compress - options; compression>` [:ref:`string <string>`] (default: ``'auto'``) (choices: "auto", "stored", "deflated", "bzip2", "lzma") Compression algorithm. Use auto to let KiBot select a suitable one.
11+
- ``expand_dest`` :index:`: <pair: output - compress - options; expand_dest>` [:ref:`boolean <boolean>`] (default: ``true``) Also expand the `dest` file name (using % patterns).
1112
- ``follow_links`` :index:`: <pair: output - compress - options; follow_links>` [:ref:`boolean <boolean>`] (default: ``true``) Store the file pointed by symlinks, not the symlink.
1213
- ``move_files`` :index:`: <pair: output - compress - options; move_files>` [:ref:`boolean <boolean>`] (default: ``false``) Move the files to the archive. In other words: remove the files after adding them to the archive.
1314
- *remove_files* :index:`: <pair: output - compress - options; remove_files>` Alias for move_files.

kibot/out_compress.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ def __init__(self):
9191
""" Store the file pointed by symlinks, not the symlink """
9292
self.skip_not_run = False
9393
""" Skip outputs with `run_by_default: false` """
94+
self.expand_dest = True
95+
""" Also expand the `dest` file name (using % patterns) """
9496
super().__init__()
9597

9698
def config(self, parent):
@@ -223,7 +225,8 @@ def get_files(self, output, no_out_run=False):
223225
# Compute the destination directory inside the archive
224226
dest = fname
225227
if f.dest:
226-
dest = os.path.join(f.dest, os.path.basename(fname))
228+
dest_exp = f.expand_filename_both(f.dest, make_safe=False) if self.expand_dest else f.dest
229+
dest = os.path.join(dest_exp, os.path.basename(fname))
227230
else:
228231
dest = os.path.relpath(dest, out_dir)
229232
files[fname_real] = dest

tests/GUI/outputs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,6 +1971,13 @@
19711971
"DataTypeBoolean"
19721972
],
19731973
null
1974+
],
1975+
[
1976+
"expand_dest",
1977+
[
1978+
"DataTypeBoolean"
1979+
],
1980+
null
19741981
]
19751982
]
19761983
]

tests/GUI/stats

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
53 outputs types with a total of 2128 different parameters
2-
Single type parameters: 1942 (91 %)
1+
53 outputs types with a total of 2129 different parameters
2+
Single type parameters: 1943 (91 %)
33
Multi type parameters: 186 (9 %)
44
Average parameters: 40
55
Maximum number of parameters: 217
@@ -40,12 +40,12 @@ Outputs sorted by parameters:
4040
- download_datasheets: 23
4141
- jobset: 24
4242
- kicanvas: 24
43-
- compress: 25
4443
- dxf_sch_print: 25
4544
- pdf_sch_print: 25
4645
- ps_sch_print: 25
4746
- qr_lib: 25
4847
- svg_sch_print: 25
48+
- compress: 26
4949
- ipc2581: 26
5050
- kiri: 26
5151
- navigate_results: 26
@@ -148,7 +148,7 @@ Outputs sorted by depth:
148148
--------------------------------------------------------------------------------
149149
14 different data types
150150
- String: 924
151-
- Boolean: 536
151+
- Boolean: 537
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: 471
167+
- Boolean: 472
168168
- ListStringSingular: 285
169169
- Number: 196
170170
- Choice: 107
@@ -403,8 +403,8 @@ Used as single data type:
403403
- Number,String: 15
404404
================================================================================
405405
================================================================================
406-
92 totals types with a total of 2507 different parameters
407-
Single type parameters: 2297 (92 %)
406+
92 totals types with a total of 2508 different parameters
407+
Single type parameters: 2298 (92 %)
408408
Multi type parameters: 210 (8 %)
409409
Average parameters: 27
410410
Maximum number of parameters: 217
@@ -481,14 +481,14 @@ Totals sorted by parameters:
481481
- jobset: 24
482482
- kicanvas: 24
483483
- kibom: 24
484-
- compress: 25
485484
- dxf_sch_print: 25
486485
- pdf_sch_print: 25
487486
- ps_sch_print: 25
488487
- qr_lib: 25
489488
- svg_sch_print: 25
490489
- ibom: 25
491490
- kicost: 25
491+
- compress: 26
492492
- ipc2581: 26
493493
- kiri: 26
494494
- navigate_results: 26
@@ -631,7 +631,7 @@ Totals sorted by depth:
631631
--------------------------------------------------------------------------------
632632
14 different data types
633633
- String: 1080
634-
- Boolean: 636
634+
- Boolean: 637
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: 563
650+
- Boolean: 564
651651
- ListStringSingular: 315
652652
- Number: 231
653653
- Choice: 139

0 commit comments

Comments
 (0)