.. _`utils/cairosvg`: CAIROSVG ======== .. image:: https://img.shields.io/github/issues-pr/snakemake/snakemake-wrappers/utils/cairosvg?label=version%20update%20pull%20requests :target: https://github.com/snakemake/snakemake-wrappers/pulls?q=is%3Apr+is%3Aopen+label%3Autils/cairosvg Convert SVG files with cairosvg. Example ------- This wrapper can be used in the following way: .. code-block:: python rule: input: "{prefix}.svg" output: "{prefix}.{fmt,(pdf|png)}" wrapper: "v3.0.1/utils/cairosvg" Note that input, output and log file paths can be chosen freely. When running with .. code-block:: bash snakemake --use-conda the software dependencies will be automatically deployed into an isolated environment before execution. Software dependencies --------------------- * ``cairosvg=2.7.1`` Authors ------- * Johannes Köster Code ---- .. code-block:: python __author__ = "Johannes Köster" __copyright__ = "Copyright 2017, Johannes Köster" __email__ = "johannes.koester@protonmail.com" __license__ = "MIT" import os from snakemake.shell import shell extra = snakemake.params.get("extra", "") log = snakemake.log_fmt_shell(stdout=True, stderr=True) _, ext = os.path.splitext(snakemake.output[0]) if ext not in (".png", ".pdf", ".ps", ".svg"): raise ValueError("invalid file extension: '{}'".format(ext)) fmt = ext[1:] shell("cairosvg -f {fmt} {snakemake.input[0]} -o {snakemake.output[0]}") .. |nl| raw:: html