Package: gamera / 1:3.4.2+git20160808.1725654-1

0001-constant-seed-for-docs.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
From 3a711c7300b04e122717945b5556cd931cfa4050 Mon Sep 17 00:00:00 2001
From: Reiner Herrmann <reiner@reiner-h.de>
Date: Sat, 17 Oct 2015 18:38:46 +0200
Subject: constant-seed-for-docs

   Use constant seed for example images. Importing random will seed the prng
   with the current system time, which will produce different example images
   on every build. To make the build reproducible, use a constant seed value.
   Author: Reiner Herrmann <reiner@reiner-h.de>
   Bug: https://bugs.debian.org/775228
   Forwarded: no
---
 gamera/plugins/draw.py | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/gamera/plugins/draw.py b/gamera/plugins/draw.py
index 006d1f6..39ce1ab 100644
--- a/gamera/plugins/draw.py
+++ b/gamera/plugins/draw.py
@@ -61,8 +61,9 @@ class draw_marker(PluginFunction):
   author = "Michael Droettboom"
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(100, 100), RGB, DENSE)
     points = [(randint(0, 100), randint(0, 100)) for x in range(4)]
     image.draw_bezier(*tuple(list(points) + [RGBPixel(255, 0, 0), 0.1]))
@@ -106,8 +107,9 @@ class draw_line(PluginFunction):
   __call__ = staticmethod(__call__)
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(100, 100), RGB, DENSE)
     for i in range(10):
       image.draw_line((randint(0, 100), randint(0, 100)),
@@ -160,8 +162,9 @@ class draw_hollow_rect(PluginFunction):
   __call__ = staticmethod(__call__)
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(100, 100), RGB, DENSE)
     for i in range(10):
       image.draw_hollow_rect((randint(0, 100), randint(0, 100)),
@@ -199,8 +202,9 @@ class draw_filled_rect(PluginFunction):
   __call__ = staticmethod(__call__)
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(100, 100), RGB, DENSE)
     for i in range(10):
       image.draw_filled_rect((randint(0, 100), randint(0, 100)),
@@ -244,8 +248,9 @@ class draw_bezier(PluginFunction):
   __call__ = staticmethod(__call__)
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(100, 100), RGB, DENSE)
     for i in range(10):
       image.draw_bezier((randint(0, 100), randint(0, 100)),
@@ -292,8 +297,9 @@ class draw_circle(PluginFunction):
   __call__ = staticmethod(__call__)
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(100, 100), RGB, DENSE)
     for i in range(10):
       image.draw_circle((randint(0, 100), randint(0, 100)),
@@ -447,8 +453,9 @@ class draw_text(PluginFunction):
   __call__ = staticmethod(__call__)
 
   def __doc_example1__(images):
-    from random import randint
+    from random import randint, seed
     from gamera.core import Image, Dim
+    seed(0)
     image = Image((0, 0), Dim(320, 300), RGB, DENSE)
 
     # These are some various Unicode encoded names of different