diff options
author | jaseg <git@jaseg.de> | 2022-06-26 17:38:55 +0200 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2022-06-26 17:38:55 +0200 |
commit | 68ce1505f1e877ffef93993bfd97c12d597341f6 (patch) | |
tree | 65fdc6956e211690d1f79dff5bd985c310427c2e /export_protoboards.py | |
parent | 25ebdbe625b69454edfc6d505d692e44f3848fcc (diff) | |
download | gerbolyze-68ce1505f1e877ffef93993bfd97c12d597341f6.tar.gz gerbolyze-68ce1505f1e877ffef93993bfd97c12d597341f6.tar.bz2 gerbolyze-68ce1505f1e877ffef93993bfd97c12d597341f6.zip |
protoboards: WIP
Diffstat (limited to 'export_protoboards.py')
-rw-r--r-- | export_protoboards.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/export_protoboards.py b/export_protoboards.py new file mode 100644 index 0000000..fe3aadf --- /dev/null +++ b/export_protoboards.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +import multiprocessing as mp +import subprocess +import pathlib + +import click +from tqdm import tqdm + +def process_file(indir, outdir, inpath): + outpath = outdir / inpath.relative_to(indir).with_suffix('.zip') + outpath.parent.mkdir(parents=True, exist_ok=True) + subprocess.run('python3 -m gerbolyze convert --zip --pattern-complete-tiles-only --use-apertures-for-patterns'.split() + [inpath, outpath], + check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + +@click.command() +@click.argument('indir', type=click.Path(exists=True, file_okay=False, dir_okay=True, path_type=pathlib.Path)) +def export(indir): + jobs = list(indir.glob('svg/**/*.svg')) + with tqdm(total = len(jobs)) as tq: + with mp.Pool() as pool: + results = [ pool.apply_async(process_file, (indir / 'svg', indir / 'gerber', path), callback=lambda _res: tq.update(1)) for path in jobs ] + results = [ res.get() for res in results ] + +if __name__ == '__main__': + export() |