How to use the scour.scour.start 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 scour-project / scour / View on Github external
def test_start(self):
        options = ScourOptions
        input = open('unittests/minimal.svg', 'rb')
        output = open('testscour_temp.svg', 'wb')

        stdout_temp = sys.stdout
        sys.stdout = None
            start(options, input, output)
            fail = False
        except Exception:
            fail = True
        sys.stdout = stdout_temp


        self.assertEqual(fail, False,
                         'Exception when calling "start" with empty options object')
github swcarpentry / python-novice-inflammation / fig / View on Github external
options.strip_xml_prolog = True
    options.strip_xml_space_attribute = True
    options.remove_titles = True
    options.remove_descriptions = True
    options.remove_metadata = True
    options.remove_descriptive_elements = True
    options.quiet = True

    for file in files:
        options.infilename = file
        options.outfilename = file[:-4] + "-scoured.svg"

            # .start will close the files. Weird flex but ok
            with open(file, 'rb') as infile, open(options.outfilename, 'wb') as outfile:
                scour.start(options, infile, outfile)
        except FileNotFoundError:
            # Doing this because we have a list of
            # hard-coded file names
            print(f"File {file} not found")
            print("Failed to optimize:", file)
            if not infile.closed: infile.close()
            if not outfile.closed: outfile.close()
            if Path(options.outfilename).is_file():