annotate en/examples/run-example @ 14:e2aa527bafa0

Describe unified diffs
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 03 Jul 2006 17:12:11 -0700
parents 69d90ab9fd80
children 187702df428b 5ad16196cef4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1 #!/usr/bin/python
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
2 #
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
3 # This program takes something that resembles a shell script and runs
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
4 # it, spitting input (commands from the script) and output into text
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
5 # files, for use in examples.
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
6
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
7 import cStringIO
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
8 import os
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
9 import pty
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
10 import re
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
11 import shutil
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
12 import signal
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
13 import sys
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
14 import tempfile
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
15 import time
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
16
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
17 def tex_escape(s):
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
18 if '\\' in s:
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
19 s = s.replace('\\', '\\\\')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
20 if '{' in s:
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
21 s = s.replace('{', '\\{')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
22 if '}' in s:
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
23 s = s.replace('}', '\\}')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
24 return s
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
25
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
26 class example:
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
27 shell = '/bin/bash'
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
28 prompt = '__run_example_prompt__\n'
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
29 pi_re = re.compile('#\$\s*(name):\s*(.*)$')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
30
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
31 def __init__(self, name):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
32 self.name = name
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
33
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
34 def parse(self):
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
35 '''yield each hunk of input from the file.'''
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
36 fp = open(self.name)
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
37 cfp = cStringIO.StringIO()
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
38 for line in fp:
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
39 cfp.write(line)
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
40 if not line.rstrip().endswith('\\'):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
41 yield cfp.getvalue()
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
42 cfp.seek(0)
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
43 cfp.truncate()
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
44
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
45 def status(self, s):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
46 sys.stdout.write(s)
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
47 if not s.endswith('\n'):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
48 sys.stdout.flush()
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
49
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
50 def send(self, s):
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
51 self.cfp.write(s)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
52 self.cfp.flush()
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
53
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
54 def receive(self):
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
55 out = cStringIO.StringIO()
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
56 while True:
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
57 s = self.cfp.readline().replace('\r\n', '\n')
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
58 if not s or s == self.prompt:
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
59 break
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
60 out.write(s)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
61 return out.getvalue()
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
62
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
63 def sendreceive(self, s):
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
64 self.send(s)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
65 r = self.receive()
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
66 if r.startswith(s):
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
67 r = r[len(s):]
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
68 return r
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
69
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
70 def run(self):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
71 ofp = None
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
72 basename = os.path.basename(self.name)
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
73 self.status('running %s ' % basename)
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
74 tmpdir = tempfile.mkdtemp(prefix=basename)
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
75 rcfile = os.path.join(tmpdir, '.bashrc')
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
76 rcfp = open(rcfile, 'w')
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
77 print >> rcfp, 'PS1="%s"' % self.prompt
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
78 print >> rcfp, 'unset HISTFILE'
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
79 print >> rcfp, 'export LANG=C'
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
80 print >> rcfp, 'export LC_ALL=C'
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
81 print >> rcfp, 'export TZ=GMT'
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
82 print >> rcfp, 'export HGRC="%s/.hgrc"' % tmpdir
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
83 print >> rcfp, 'export HGRCPATH=$HGRC'
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
84 print >> rcfp, 'cd %s' % tmpdir
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
85 rcfp.close()
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
86 pid, fd = pty.fork()
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
87 if pid == 0:
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
88 #os.execl(self.shell, self.shell)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
89 os.system('/bin/bash --noediting --noprofile --rcfile %s' % rcfile)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
90 sys.exit(0)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
91 self.cfp = os.fdopen(fd, 'w+')
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
92 try:
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
93 self.receive()
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
94 for hunk in self.parse():
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
95 # is this line a processing instruction?
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
96 m = self.pi_re.match(hunk)
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
97 if m:
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
98 pi, rest = m.groups()
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
99 if pi == 'name':
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
100 self.status('.')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
101 out = rest
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
102 assert os.sep not in out
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
103 if out:
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
104 ofp = open('%s.%s.out' % (self.name, out), 'w')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
105 else:
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
106 ofp = None
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
107 elif hunk.strip():
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
108 # it's something we should execute
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
109 output = self.sendreceive(hunk)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
110 if not ofp:
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
111 continue
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
112 # first, print the command we ran
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
113 if not hunk.startswith('#'):
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
114 nl = hunk.endswith('\n')
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
115 hunk = ('$ \\textbf{%s}' %
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
116 tex_escape(hunk.rstrip('\n')))
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
117 if nl: hunk += '\n'
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
118 ofp.write(hunk)
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
119 # then its output
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
120 ofp.write(output)
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
121 self.status('\n')
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
122 finally:
6
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
123 try:
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
124 output = self.sendreceive('exit\n')
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
125 if ofp:
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
126 ofp.write(output)
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
127 self.cfp.close()
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
128 except IOError:
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
129 pass
69d90ab9fd80 Really run example command sequences under a single shell.
Bryan O'Sullivan <bos@serpentine.com>
parents: 4
diff changeset
130 os.kill(pid, signal.SIGTERM)
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
131 os.wait()
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
132 shutil.rmtree(tmpdir)
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
133
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
134 def main(path='.'):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
135 args = sys.argv[1:]
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
136 if args:
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
137 for a in args:
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
138 example(a).run()
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
139 return
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
140 for name in os.listdir(path):
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
141 if name == 'run-example' or name.startswith('.'): continue
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
142 if name.endswith('.out') or name.endswith('~'): continue
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
143 example(os.path.join(path, name)).run()
4
33a2e7b9978d Make it possible to include example input and output from real programs.
Bryan O'Sullivan <bos@serpentine.com>
parents: 3
diff changeset
144 print >> open(os.path.join(path, '.run'), 'w'), time.asctime()
3
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
145
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
146 if __name__ == '__main__':
906d9021f9e5 Making progress on autogenerated example output.
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
147 main()