Now you can compress files relative to the current working directory.
Related to #93
This commit is contained in:
parent
c02a4f814d
commit
a82f130ad9
|
|
@ -47,6 +47,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
(#103)
|
||||
- A mechanism to avoid running some outputs by default. (#112)
|
||||
- New pre-flight commands to replace tags in the schematic and PCB. (#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)
|
||||
|
||||
### Changed
|
||||
- Internal BoM: now components with different Tolerance, Voltage, Current
|
||||
|
|
|
|||
|
|
@ -879,10 +879,12 @@ Next time you need this list just use an alias, like this:
|
|||
* Valid keys:
|
||||
- `dest`: [string=''] Destination directory inside the archive, empty means the same of the file.
|
||||
- `filter`: [string='.*'] A regular expression that source files must match.
|
||||
- `from_cwd`: [boolean=false] Use the current working directory instead of the dir specified by `-d`.
|
||||
- `from_output`: [string=''] Collect files from the selected output.
|
||||
When used the `source` option is ignored.
|
||||
- `source`: [string='*'] File names to add, wildcards allowed. Use ** for recursive match.
|
||||
Note this pattern is applied to the output dir specified with -d comman line option.
|
||||
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.
|
||||
- `output`: [string='%f-%i%v.%x'] Name for the generated archive (%i=name of the output %x=according to format). Affected by global options.
|
||||
- `run_by_default`: [boolean=true] When enabled this output will be created when no specific outputs are requested.
|
||||
|
|
|
|||
|
|
@ -275,11 +275,14 @@ outputs:
|
|||
- dest: ''
|
||||
# [string='.*'] A regular expression that source files must match
|
||||
filter: '.*'
|
||||
# [boolean=false] Use the current working directory instead of the dir specified by `-d`
|
||||
from_cwd: false
|
||||
# [string=''] Collect files from the selected output.
|
||||
# When used the `source` option is ignored
|
||||
from_output: ''
|
||||
# [string='*'] File names to add, wildcards allowed. Use ** for recursive match.
|
||||
# Note this pattern is applied to the output dir specified with -d comman line option
|
||||
# By default this pattern is applied to the output dir specified with `-d` command line option.
|
||||
# See the `from_cwd` option
|
||||
source: '*'
|
||||
# [string='ZIP'] [ZIP,TAR,RAR] Output file format
|
||||
format: 'ZIP'
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ class FilesList(Optionable):
|
|||
with document:
|
||||
self.source = '*'
|
||||
""" File names to add, wildcards allowed. Use ** for recursive match.
|
||||
Note this pattern is applied to the output dir specified with -d comman line option """
|
||||
By default this pattern is applied to the output dir specified with `-d` command line option.
|
||||
See the `from_cwd` option """
|
||||
self.from_cwd = False
|
||||
""" Use the current working directory instead of the dir specified by `-d` """
|
||||
self.from_output = ''
|
||||
""" Collect files from the selected output.
|
||||
When used the `source` option is ignored """
|
||||
|
|
@ -118,7 +121,8 @@ class CompressOptions(BaseOptions):
|
|||
def get_files(self, output, no_out_run=False):
|
||||
output_real = os.path.realpath(output)
|
||||
files = OrderedDict()
|
||||
out_dir = self.expand_filename_sch(GS.out_dir)
|
||||
out_dir_cwd = os.getcwd()
|
||||
out_dir_default = self.expand_filename_sch(GS.out_dir)
|
||||
for f in self.files:
|
||||
# Get the list of candidates
|
||||
files_list = None
|
||||
|
|
@ -143,6 +147,7 @@ class CompressOptions(BaseOptions):
|
|||
logger.error('Unable to generate `{}` from {}'.format(file, out))
|
||||
exit(INTERNAL_ERROR)
|
||||
else:
|
||||
out_dir = out_dir_cwd if f.from_cwd else out_dir_default
|
||||
files_list = glob.iglob(os.path.join(out_dir, f.source), recursive=True)
|
||||
# Filter and adapt them
|
||||
for fname in filter(re.compile(f.filter).match, files_list):
|
||||
|
|
@ -155,6 +160,7 @@ class CompressOptions(BaseOptions):
|
|||
if f.dest:
|
||||
dest = os.path.join(f.dest, os.path.basename(fname))
|
||||
else:
|
||||
out_dir = out_dir_cwd if f.from_cwd else out_dir_default
|
||||
dest = os.path.relpath(dest, out_dir)
|
||||
files[fname_real] = dest
|
||||
return files
|
||||
|
|
|
|||
|
|
@ -865,3 +865,13 @@ def test_expand_comment_1(test_dir):
|
|||
ctx.run(extra=[])
|
||||
ctx.expect_out_file(POS_DIR+'/test_v5_(Comment 1)_(The_C2).csv')
|
||||
ctx.clean_up()
|
||||
|
||||
|
||||
def test_compress_sources_1(test_dir):
|
||||
""" Disable in the same file and out-of-order """
|
||||
prj = 'test_v5'
|
||||
ctx = context.TestContext(test_dir, 'test_compress_sources_1', prj, 'compress_sources_1', '')
|
||||
ctx.run()
|
||||
files = ['source/'+prj+'.kicad_pcb', 'source/'+prj+'.sch', 'source/deeper.sch', 'source/sub-sheet.sch']
|
||||
ctx.test_compress(prj + '-result.tar.bz2', files)
|
||||
ctx.clean_up()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# Example KiBot config file
|
||||
kibot:
|
||||
version: 1
|
||||
|
||||
outputs:
|
||||
- name: result
|
||||
comment: Test tarball compress
|
||||
type: compress
|
||||
options:
|
||||
format: TAR
|
||||
compression: bzip2
|
||||
files:
|
||||
- source: tests/board_samples/kicad_5/test_v5.*
|
||||
from_cwd: true
|
||||
dest: source
|
||||
- source: tests/board_samples/kicad_5/deeper.sch
|
||||
from_cwd: true
|
||||
dest: source
|
||||
- source: tests/board_samples/kicad_5/sub-sheet.sch
|
||||
from_cwd: true
|
||||
dest: source
|
||||
|
||||
Loading…
Reference in New Issue