Revision: 7972 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7972&view=rev Author: mdboom Date: 2009-11-18 16:19:21 +0000 (Wed, 18 Nov 2009)
Log Message: ----------- Fix plot directive so it handles source files in various encodings. Modified Paths: -------------- branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py Modified: branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py =================================================================== --- branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-11-16 23:53:13 UTC (rev 7971) +++ branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py 2009-11-18 16:19:21 UTC (rev 7972) @@ -36,7 +36,7 @@ sphinx_version = sphinx.__version__.split(".") # The split is necessary for sphinx beta versions where the string is # '6b1' -sphinx_version = tuple([int(re.split('[a-z]', x)[0]) +sphinx_version = tuple([int(re.split('[a-z]', x)[0]) for x in sphinx_version[:2]]) import matplotlib @@ -96,7 +96,8 @@ 'scale': directives.nonnegative_int, 'align': align, 'class': directives.class_option, - 'include-source': directives.flag } + 'include-source': directives.flag, + 'encoding': directives.encoding} template = """ .. htmlonly:: @@ -294,8 +295,15 @@ if options.has_key('include-source'): if content is None: - content = open(reference, 'r').read() - lines = ['::', ''] + [' %s'%row.rstrip() for row in content.split('\n')] + lines = [ + '.. include:: %s' % os.path.join(setup.app.builder.srcdir, reference), + ' :literal:'] + if options.has_key('encoding'): + lines.append(' :encoding: %s' % options['encoding']) + del options['encoding'] + else: + lines = ['::', ''] + [' %s'%row.rstrip() for row in content.split('\n')] + lines.append('') del options['include-source'] else: lines = [] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins