How to use the scour.scour function in scour

To help you get started, we’ve selected a few scour examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github larq / larq / View on Github external
def html_format(source, language, css_class, options, md):
    function = reduce(getattr, [lq, *source.split(".")])
    fig = plot(function)
    tmp = StringIO()
    fig.savefig(tmp, format="svg", bbox_inches="tight", pad_inches=0)
    return scour.scourString(tmp.getvalue().replace("DejaVu Sans", "sans-serif"))
github swcarpentry / python-novice-inflammation / fig / View on Github external
process =, capture_output=True)
    if not process.stderr:
        output = process.stdout.decode("ascii").split()
        if __name__ == '__main__':
            print("Found 'svgo' version", output[0])

    # Check if we have scour
        from scour import scour
    except ImportError:
        if __name__ == '__main__':
            print("Found 'scour' version", scour.__version__)

    return available_optimizers
github swcarpentry / python-novice-inflammation / fig / View on Github external
def optimize_with_scour(files):
    from scour import scour
    Optimize SVG files using Scour.

    # Configure scour
    options = scour.parse_args()

    options.digits = 4
    # values lower than 4 for '.digits' led to visilble differences between
    # the original and 'optimized' file
    options.indent_depth = 2
    options.simple_colors = False
    options.enable_viewboxing = True
    options.embed_rasters = True
    options.group_create = True
    options.group_collapse = True
    options.shorten_ids = True
    options.strip_comments = True
    options.strip_ids = True
    options.strip_xml_prolog = True
    options.strip_xml_space_attribute = True
    options.remove_titles = True