Added an option to remove the files we compressed.

Closes #192
This commit is contained in:
Salvador E. Tropea 2022-04-20 13:43:41 -03:00
parent ff41012e84
commit 5d9b047d81
4 changed files with 18 additions and 3 deletions

View File

@ -60,9 +60,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Also a mechanism to define variables in KiCad 6. (#161)
- Annotate power components. (#76)
- Annotate according to PCB coordinates (#93)
- Now you can compress files relative to the current working directory.
So you can create a compressed file containing the source schematic and
PCB files. (#93)
- Compress:
- Now you can compress files relative to the current working directory.
So you can create a compressed file containing the source schematic and
PCB files. (#93)
- Added an option to remove the files we compressed. (#192)
- Support for new KiCost options `split_extra_fields` and `board_qty`. (#120)
- Datasheet downloader. (#119)
- Position files now can include virtual components. (#106)

View File

@ -1174,7 +1174,9 @@ Next time you need this list just use an alias, like this:
By default this pattern is applied to the output dir specified with `-d` command line option.
See the `from_cwd` option.
- `format`: [string='ZIP'] [ZIP,TAR,RAR] Output file format.
- `move_files`: [boolean=false] Move the files to the archive. In other words: remove the files after adding them to the archive.
- `output`: [string='%f-%i%I%v.%x'] Name for the generated archive (%i=name of the output %x=according to format). Affected by global options.
- *remove_files*: Alias for move_files.
- `output_id`: [string=''] Text to use for the %I expansion content. To differentiate variations of this output.
- `run_by_default`: [boolean=true] When enabled this output will be created when no specific outputs are requested.

View File

@ -390,8 +390,11 @@ outputs:
source: '*'
# [string='ZIP'] [ZIP,TAR,RAR] Output file format
format: 'ZIP'
# [boolean=false] Move the files to the archive. In other words: remove the files after adding them to the archive
move_files: false
# [string='%f-%i%I%v.%x'] Name for the generated archive (%i=name of the output %x=according to format). Affected by global options
output: '%f-%i%I%v.%x'
# `remove_files` is an alias for `move_files`
# Datasheets downloader:
- name: 'download_datasheets_example'
comment: 'Downloads the datasheets for the project'

View File

@ -64,6 +64,10 @@ class CompressOptions(BaseOptions):
""" [auto,stored,deflated,bzip2,lzma] Compression algorithm. Use auto to let KiBot select a suitable one """
self.files = FilesList
""" [list(dict)] Which files will be included """
self.move_files = False
""" Move the files to the archive. In other words: remove the files after adding them to the archive """
self.remove_files = None
""" {move_files} """
super().__init__()
def config(self, parent):
@ -186,6 +190,10 @@ class CompressOptions(BaseOptions):
self.create_tar(output, files)
elif self.format == 'RAR':
self.create_rar(output, files)
if self.move_files:
for fname in files.keys():
logger.debug('Removing '+fname)
os.remove(fname)
@output_class