[Python-modules-commits] [gamera] 10/20: gendoc-draw-text

Daniel Stender stender at moszumanska.debian.org
Mon Aug 8 08:55:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

stender pushed a commit to branch master
in repository gamera.

commit 74c6a2044c90748b7a7b19c92d6a9774bbc1a727
Author: Jakub Wilk <jwilk at debian.org>
Date:   Sat Oct 17 18:55:55 2015 +0200

    gendoc-draw-text
    
       use a pre-built image for the draw_text plugin documentation example if X
       server is not available.
       Forwarded: not-needed
       Reviewed-by: Daniel Stender <debian at danielstender.com>
---
 doc/draw_text_helper.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 doc/gendoc.py           |  2 ++
 2 files changed, 48 insertions(+)

diff --git a/doc/draw_text_helper.py b/doc/draw_text_helper.py
new file mode 100644
index 0000000..63613d0
--- /dev/null
+++ b/doc/draw_text_helper.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+# This script (including  the following line) was generated by running itself:
+DATA = 320, 300, 'QlpoOTFBWSZTWdT8V9AAWJt//5JJJJJJJpJZJJJBIpCpJJJJJppNpLJJJIBJJEKVJJLI4A/ufO53Prd6Mni97e15cWWKl3prPPd7eeNnbwdWntjmcc3tyAHoZvduEiQQnop6BTap4EnkjT1NPTUMTamRpp6gDQB6mjIJETIiapijGSDIA0aAAaGgAAAADhoZNNDTI0NMjIMjI0MgMTRk0AZMjEMJNSJNBMmTCamjTKAGgNqPUGjQAGgAHqApKpKbTaICNGifqBPQEMI9QwAGpkYAnoAIkiaelIZFNT1P0oaA0DR6magANAABoDQPagQc/V5u+jPOOthnhRyPQ0BV7HVgNrJhTdUAuymBSUwmoQmoScE+f5aDbk21aqrVyDSMARwBCFJOcQ3sIZECzwYTB4488CGYm4PfFJFDpDEO05LlI90SiLqei/RhTExF1LPDphJx6KwVnuzkkpqk64N0UuMeSz [...]
+
+import sys
+import os
+import bz2
+import base64
+
+from gamera.core import init_gamera, Point, Dim, RGB, DENSE
+from gamera import plugin
+from gamera.plugins.draw import draw_text
+from gamera.plugins.string_io import _from_raw_string
+
+sys.stdout = file(os.devnull, 'w')
+init_gamera()
+sys.stdout = sys.__stdout__
+
+if __name__ == '__main__':
+	if not os.getenv('DISPLAY'):
+		print >>sys.stderr, 'This script needs access to an X server'
+		sys.exit(1)
+	import wxversion
+	wxversion.select(['2.8', '2.6', '2.5', '2.4'])
+	image = draw_text().__doc_example1__()
+	raw_string = image._to_raw_string()
+	bz2_string = bz2.compress(raw_string)
+	base64_string = base64.b64encode(bz2_string)
+	for line in open(__file__, 'rt'):
+		if line.startswith('DATA = '):
+			sys.stdout.write('DATA = %d, %d, %r\n' % (image.dim.ncols, image.dim.nrows, base64_string))
+		else:
+			sys.stdout.write(line)
+	sys.exit(0)
+
+if not os.getenv('DISPLAY'):
+	ncols, nrows, base64_string = DATA
+	bz2_string = base64.decodestring(base64_string)
+	raw_string = bz2.decompress(bz2_string)
+	image = _from_raw_string(Point(0, 0), Dim(ncols, nrows), RGB, DENSE, raw_string)
+	def static_draw_text_example(self, image=image):
+		return image
+	plugin.plugin_methods[RGB]['Draw']['draw_text'].doc_examples = [static_draw_text_example]
+
+# vim:ts=4 sw=4 noet
diff --git a/doc/gendoc.py b/doc/gendoc.py
index 76257e1..d14b739 100755
--- a/doc/gendoc.py
+++ b/doc/gendoc.py
@@ -8,6 +8,8 @@ import gamera.paths
 
 gamera.paths.test = os.path.join(os.path.dirname(__file__), '..', 'gamera', 'test')
 
+import draw_text_helper
+
 if __name__ == "__main__":
    core.init_gamera()
    gendoc.gendoc(classes=[

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/gamera.git



More information about the Python-modules-commits mailing list