|
13 | 13 | source will be included inline, as well as a link to the source. |
14 | 14 | """ |
15 | 15 |
|
16 | | -import sys, os, glob, shutil |
| 16 | +import sys, os, glob, shutil, code |
17 | 17 | from docutils.parsers.rst import directives |
18 | 18 |
|
19 | 19 | try: |
|
26 | 26 |
|
27 | 27 |
|
28 | 28 | import matplotlib |
29 | | -import IPython.Shell |
| 29 | + |
30 | 30 | matplotlib.use('Agg') |
31 | 31 | import matplotlib.pyplot as plt |
32 | 32 |
|
33 | | -mplshell = IPython.Shell.MatplotlibShell('mpl') |
| 33 | +#import IPython.Shell |
| 34 | +#mplshell = IPython.Shell.MatplotlibShell('mpl') |
| 35 | +console = code.InteractiveConsole() |
| 36 | +def runfile(fname): |
| 37 | + source = file(fname).read() |
| 38 | + return console.runsource(source) |
34 | 39 |
|
35 | 40 | options = {'alt': directives.unchanged, |
36 | 41 | 'height': directives.length_or_unitless, |
|
58 | 63 |
|
59 | 64 | def makefig(fullpath, outdir): |
60 | 65 | """ |
61 | | - run a pyplot script and save the low and high res PNGs and a PDF in _static |
| 66 | + run a pyplot script<t and save the low and high res PNGs and a PDF in _static |
62 | 67 | """ |
63 | 68 |
|
64 | 69 | fullpath = str(fullpath) # todo, why is unicode breaking this |
@@ -88,7 +93,8 @@ def makefig(fullpath, outdir): |
88 | 93 | plt.close('all') # we need to clear between runs |
89 | 94 | matplotlib.rcdefaults() |
90 | 95 |
|
91 | | - mplshell.magic_run(fullpath) |
| 96 | + runfile(fullpath) |
| 97 | + |
92 | 98 | for format, dpi in formats: |
93 | 99 | outname = os.path.join(outdir, '%s.%s' % (basename, format)) |
94 | 100 | if os.path.exists(outname): continue |
|
0 commit comments