generate-dot-to-png.py 824 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. # Copyright 2018 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """The diagrams included in the network stack documentation were
  6. generated with Graphviz, and both source (.dot) and output (.svg) are
  7. included in the repository. If graphviz is installed, the output may
  8. be regenerated by running this script."""
  9. import glob
  10. import os
  11. import subprocess
  12. def main():
  13. for dot_filename in glob.glob("*.dot"):
  14. png_filename = os.path.splitext(dot_filename)[0] + ".png"
  15. print "Generating %s from %s" % (png_filename, dot_filename)
  16. subprocess.check_call(["dot", "-Tpng", dot_filename, "-o", png_filename])
  17. subprocess.check_call(["optipng", png_filename])
  18. if __name__ == "__main__":
  19. main()