[cairo-commit] pycairo/examples/cairo_snippets snippets_pdf.py, 1.7, 1.8 snippets_png.py, 1.7, 1.8 snippets_ps.py, 1.2, 1.3

Steve Chaplin commit at pdx.freedesktop.org
Tue Jun 21 17:48:09 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/examples/cairo_snippets
In directory gabe:/tmp/cvs-serv16628/examples/cairo_snippets

Modified Files:
	snippets_pdf.py snippets_png.py snippets_ps.py 
Log Message:
SC

Index: snippets_pdf.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_pdf.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- snippets_pdf.py	15 Jun 2005 11:47:12 -0000	1.7
+++ snippets_pdf.py	22 Jun 2005 00:48:07 -0000	1.8
@@ -2,22 +2,25 @@
 """Python version of cairo-demo/cairo_snippets/cairo_snippets_pdf.c
 create a file for each example rather than one large file for all examples
 """
+
 from __future__ import division
 from math import pi as M_PI  # used by many snippets
 import sys
 
 import cairo
+if not cairo.HAS_PDF_SURFACE:
+    raise SystemExit ('cairo was not compiled with PDF support')
 
 from snippets import snip_list, snippet_normalize, snippet_set_bg_svg
 
+
 width_in_inches, height_in_inches = 2, 2
 width_in_points, height_in_points = width_in_inches * 72, height_in_inches * 72
 width, height = width_in_points, height_in_points # used by snippet_normalize()
 
-Verbose_mode = True
 
 def do_snippet (snippet):
-    if Verbose_mode:
+    if verbose_mode:
         print 'processing %s' % snippet,
     
     filename = 'snippets/%s.pdf' % snippet
@@ -29,17 +32,18 @@
         execfile ('snippets/%s.py' % snippet, globals(), locals())
     except:
         exc_type, exc_value = sys.exc_info()[:2] 
-        print exc_type, exc_value
+        print >> sys.stderr, exc_type, exc_value
     else:
         cr.restore()
         cr.show_page()
     
-    if Verbose_mode:
+    if verbose_mode:
         print
 
 if __name__ == '__main__':
+    verbose_mode = True
     if len(sys.argv) > 1 and sys.argv[1] == '-s':
-        Verbose_mode=False
+        verbose_mode = False
         del sys.argv[1]
     
     if len(sys.argv) > 1: # do specified snippets

Index: snippets_png.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_png.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- snippets_png.py	9 May 2005 00:52:46 -0000	1.7
+++ snippets_png.py	22 Jun 2005 00:48:07 -0000	1.8
@@ -1,24 +1,27 @@
 #!/usr/bin/env python
 """Python version of cairo-demo/cairo_snippets/cairo_snippets_png.c
 """
+
 from __future__ import division
 from math import pi as M_PI  # used by many snippets
 import sys
 
 import cairo
+if not cairo.HAS_PNG_FUNCTIONS:
+    raise SystemExit ('cairo was not compiled with PNG support')
 
 from snippets import snip_list, snippet_normalize, snippet_set_bg_svg
 
+
 width, height = 256, 256 # used by snippet_normalize()
-Verbose_mode = True
 
 
 def do_snippet (snippet):
-    if Verbose_mode:
+    if verbose_mode:
         print 'processing %s' % snippet,
     
-    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
-    cr = cairo.Context(surface)
+    surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, width, height)
+    cr = cairo.Context (surface)
 
     cr.save()
     try:
@@ -30,12 +33,13 @@
         cr.restore()
         surface.write_to_png ('snippets/%s.png' % snippet)
 
-    if Verbose_mode:
+    if verbose_mode:
         print
 
 if __name__ == '__main__':
+    verbose_mode = True
     if len(sys.argv) > 1 and sys.argv[1] == '-s':
-        Verbose_mode=False
+        verbose_mode = False
         del sys.argv[1]
     
     if len(sys.argv) > 1: # do specified snippets

Index: snippets_ps.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_ps.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- snippets_ps.py	15 Jun 2005 11:47:12 -0000	1.2
+++ snippets_ps.py	22 Jun 2005 00:48:07 -0000	1.3
@@ -2,22 +2,25 @@
 """Python version of cairo-demo/cairo_snippets/cairo_snippets_ps.c
 create a file for each example rather than one large file for all examples
 """
+
 from __future__ import division
 from math import pi as M_PI  # used by many snippets
 import sys
 
 import cairo
+if not cairo.HAS_PS_SURFACE:
+    raise SystemExit ('cairo was not compiled with PS support')
 
 from snippets import snip_list, snippet_normalize, snippet_set_bg_svg
 
+
 width_in_inches, height_in_inches = 2, 2
 width_in_points, height_in_points = width_in_inches * 72, height_in_inches * 72
 width, height = width_in_points, height_in_points # used by snippet_normalize()
 
-Verbose_mode = True
 
 def do_snippet (snippet):
-    if Verbose_mode:
+    if verbose_mode:
         print 'processing %s' % snippet,
     
     filename = 'snippets/%s.ps' % snippet
@@ -34,12 +37,13 @@
         cr.restore()
         cr.show_page()
     
-    if Verbose_mode:
+    if verbose_mode:
         print
 
 if __name__ == '__main__':
+    verbose_mode = True
     if len(sys.argv) > 1 and sys.argv[1] == '-s':
-        Verbose_mode=False
+        verbose_mode = False
         del sys.argv[1]
     
     if len(sys.argv) > 1: # do specified snippets




More information about the cairo-commit mailing list