Show More
@@ -1,50 +1,61 b'' | |||
|
1 | 1 | """a mercurial extension for syntax highlighting in hgweb |
|
2 | 2 | |
|
3 | 3 | It depends on the pygments syntax highlighting library: |
|
4 | 4 | http://pygments.org/ |
|
5 | 5 | |
|
6 | 6 | To enable the extension add this to hgrc: |
|
7 | 7 | |
|
8 | 8 | [extensions] |
|
9 | 9 | hgext.highlight = |
|
10 | 10 | |
|
11 | 11 | There is a single configuration option: |
|
12 | 12 | |
|
13 | 13 | [web] |
|
14 | 14 | pygments_style = <style> |
|
15 | 15 | |
|
16 | 16 | The default is 'colorful'. |
|
17 | 17 | |
|
18 | 18 | -- Adam Hupp <adam@hupp.org> |
|
19 | 19 | """ |
|
20 | 20 | |
|
21 | 21 | import highlight |
|
22 | 22 | from mercurial.hgweb import webcommands, webutil, common |
|
23 | 23 | |
|
24 | 24 | web_filerevision = webcommands._filerevision |
|
25 | 25 | web_annotate = webcommands.annotate |
|
26 | 26 | |
|
27 | 27 | def filerevision_highlight(web, tmpl, fctx): |
|
28 | style = web.config('web', 'pygments_style', 'colorful') | |
|
29 | highlight.pygmentize('fileline', fctx, style, tmpl) | |
|
28 | mt = ''.join(tmpl('mimetype', encoding=web.encoding)) | |
|
29 | # only pygmentize for mimetype containing 'html' so we both match | |
|
30 | # 'text/html' and possibly 'application/xhtml+xml' in the future | |
|
31 | # so that we don't have to touch the extension when the mimetype | |
|
32 | # for a template changes; also hgweb optimizes the case that a | |
|
33 | # raw file is sent using rawfile() and doesn't call us, so we | |
|
34 | # can't clash with the file's content-type here in case we | |
|
35 | # pygmentize a html file | |
|
36 | if 'html' in mt: | |
|
37 | style = web.config('web', 'pygments_style', 'colorful') | |
|
38 | highlight.pygmentize('fileline', fctx, style, tmpl) | |
|
30 | 39 | return web_filerevision(web, tmpl, fctx) |
|
31 | 40 | |
|
32 | 41 | def annotate_highlight(web, req, tmpl): |
|
33 | fctx = webutil.filectx(web.repo, req) | |
|
34 | style = web.config('web', 'pygments_style', 'colorful') | |
|
35 | highlight.pygmentize('annotateline', fctx, style, tmpl) | |
|
42 | mt = ''.join(tmpl('mimetype', encoding=web.encoding)) | |
|
43 | if 'html' in mt: | |
|
44 | fctx = webutil.filectx(web.repo, req) | |
|
45 | style = web.config('web', 'pygments_style', 'colorful') | |
|
46 | highlight.pygmentize('annotateline', fctx, style, tmpl) | |
|
36 | 47 | return web_annotate(web, req, tmpl) |
|
37 | 48 | |
|
38 | 49 | def generate_css(web, req, tmpl): |
|
39 | 50 | pg_style = web.config('web', 'pygments_style', 'colorful') |
|
40 | 51 | fmter = highlight.HtmlFormatter(style = pg_style) |
|
41 | 52 | req.respond(common.HTTP_OK, 'text/css') |
|
42 | 53 | return ['/* pygments_style = %s */\n\n' % pg_style, fmter.get_style_defs('')] |
|
43 | 54 | |
|
44 | 55 | |
|
45 | 56 | # monkeypatch in the new version |
|
46 | 57 | |
|
47 | 58 | webcommands._filerevision = filerevision_highlight |
|
48 | 59 | webcommands.annotate = annotate_highlight |
|
49 | 60 | webcommands.highlightcss = generate_css |
|
50 | 61 | webcommands.__all__.append('highlightcss') |
@@ -1,55 +1,82 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | 3 | "$TESTDIR/hghave" pygments || exit 80 |
|
4 | 4 | |
|
5 | 5 | cat <<EOF >> $HGRCPATH |
|
6 | 6 | [extensions] |
|
7 | 7 | hgext.highlight = |
|
8 | 8 | [web] |
|
9 | 9 | pygments_style = friendly |
|
10 | 10 | EOF |
|
11 | 11 | |
|
12 | 12 | hg init test |
|
13 | 13 | cd test |
|
14 | 14 | cp $TESTDIR/get-with-headers.py ./ |
|
15 | 15 | hg ci -Ama |
|
16 | 16 | |
|
17 | 17 | echo % hg serve |
|
18 | 18 | hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
19 | 19 | cat hg.pid >> $DAEMON_PIDS |
|
20 | 20 | |
|
21 | echo % hgweb filerevision | |
|
21 | echo % hgweb filerevision, html | |
|
22 | 22 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py') \ |
|
23 | 23 | | sed "s/[0-9]* years ago/long ago/g" |
|
24 | 24 | |
|
25 | echo % hgweb fileannotate | |
|
25 | echo % hgweb fileannotate, html | |
|
26 | 26 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py') \ |
|
27 | 27 | | sed "s/[0-9]* years ago/long ago/g" |
|
28 | 28 | |
|
29 | echo % hgweb fileannotate, raw | |
|
30 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py?style=raw') \ | |
|
31 | | sed "s/test@//" > a | |
|
32 | ||
|
33 | echo "200 Script output follows" > b | |
|
34 | echo "" >> b | |
|
35 | echo "" >> b | |
|
36 | hg annotate "get-with-headers.py" >> b | |
|
37 | echo "" >> b | |
|
38 | echo "" >> b | |
|
39 | echo "" >> b | |
|
40 | echo "" >> b | |
|
41 | ||
|
42 | diff -u b a | |
|
43 | ||
|
44 | echo | |
|
45 | echo % hgweb filerevision, raw | |
|
46 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py?style=raw') \ | |
|
47 | > a | |
|
48 | ||
|
49 | echo "200 Script output follows" > b | |
|
50 | echo "" >> b | |
|
51 | hg cat get-with-headers.py >> b | |
|
52 | ||
|
53 | diff -u b a | |
|
54 | ||
|
55 | echo | |
|
29 | 56 | echo % hgweb highlightcss friendly |
|
30 | 57 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out |
|
31 | 58 | head -n 4 out |
|
32 | 59 | rm out |
|
33 | 60 | |
|
34 | 61 | echo % errors encountered |
|
35 | 62 | cat errors.log |
|
36 | 63 | kill `cat hg.pid` |
|
37 | 64 | |
|
38 | 65 | # Change the pygments style |
|
39 | 66 | cat > .hg/hgrc <<EOF |
|
40 | 67 | [web] |
|
41 | 68 | pygments_style = fruity |
|
42 | 69 | EOF |
|
43 | 70 | |
|
44 | 71 | echo % hg serve again |
|
45 | 72 | hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
46 | 73 | cat hg.pid >> $DAEMON_PIDS |
|
47 | 74 | |
|
48 | 75 | echo % hgweb highlightcss fruity |
|
49 | 76 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out |
|
50 | 77 | head -n 4 out |
|
51 | 78 | rm out |
|
52 | 79 | |
|
53 | 80 | echo % errors encountered |
|
54 | 81 | cat errors.log |
|
55 | 82 |
@@ -1,145 +1,149 b'' | |||
|
1 | 1 | adding get-with-headers.py |
|
2 | 2 | % hg serve |
|
3 | % hgweb filerevision | |
|
3 | % hgweb filerevision, html | |
|
4 | 4 | 200 Script output follows |
|
5 | 5 | |
|
6 | 6 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
7 | 7 | <html> |
|
8 | 8 | <head> |
|
9 | 9 | <link rel="icon" href="/static/hgicon.png" type="image/png"> |
|
10 | 10 | <meta name="robots" content="index, nofollow" /> |
|
11 | 11 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> |
|
12 | 12 | |
|
13 | 13 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
14 | 14 | <title>test:get-with-headers.py</title> |
|
15 | 15 | </head> |
|
16 | 16 | <body> |
|
17 | 17 | |
|
18 | 18 | <div class="buttons"> |
|
19 | 19 | <a href="/log/0">changelog</a> |
|
20 | 20 | <a href="/shortlog/0">shortlog</a> |
|
21 | 21 | <a href="/graph">graph</a> |
|
22 | 22 | <a href="/tags">tags</a> |
|
23 | 23 | <a href="/rev/79ee608ca36d">changeset</a> |
|
24 | 24 | <a href="/file/79ee608ca36d/">files</a> |
|
25 | 25 | <a href="/log/79ee608ca36d/get-with-headers.py">revisions</a> |
|
26 | 26 | <a href="/annotate/79ee608ca36d/get-with-headers.py">annotate</a> |
|
27 | 27 | <a href="/raw-file/79ee608ca36d/get-with-headers.py">raw</a> |
|
28 | 28 | </div> |
|
29 | 29 | |
|
30 | 30 | <h2>get-with-headers.py</h2> |
|
31 | 31 | |
|
32 | 32 | <table> |
|
33 | 33 | <tr> |
|
34 | 34 | <td class="metatag">changeset 0:</td> |
|
35 | 35 | <td><a href="/rev/79ee608ca36d">79ee608ca36d</a></td></tr> |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | <tr> |
|
39 | 39 | <td class="metatag">author:</td> |
|
40 | 40 | <td>test</td></tr> |
|
41 | 41 | <tr> |
|
42 | 42 | <td class="metatag">date:</td> |
|
43 | 43 | <td>Thu Jan 01 00:00:00 1970 +0000 (long ago)</td></tr> |
|
44 | 44 | <tr> |
|
45 | 45 | <td class="metatag">permissions:</td> |
|
46 | 46 | <td>-rwxr-xr-x</td></tr> |
|
47 | 47 | <tr> |
|
48 | 48 | <td class="metatag">description:</td> |
|
49 | 49 | <td>a</td> |
|
50 | 50 | </tr> |
|
51 | 51 | </table> |
|
52 | 52 | |
|
53 | 53 | <pre> |
|
54 | 54 | <div class="parity0"><a class="lineno" href="#l1" id="l1"> 1</a><span class="c">#!/usr/bin/env python</span></div><div class="parity1"><a class="lineno" href="#l2" id="l2"> 2</a></div><div class="parity0"><a class="lineno" href="#l3" id="l3"> 3</a><span class="n">__doc__</span> <span class="o">=</span> <span class="s">"""This does HTTP get requests given a host:port and path and returns</span></div><div class="parity1"><a class="lineno" href="#l4" id="l4"> 4</a><span class="s">a subset of the headers plus the body of the result."""</span></div><div class="parity0"><a class="lineno" href="#l5" id="l5"> 5</a></div><div class="parity1"><a class="lineno" href="#l6" id="l6"> 6</a><span class="k">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span></div><div class="parity0"><a class="lineno" href="#l7" id="l7"> 7</a><span class="n">headers</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">3</span><span class="p">:]]</span></div><div class="parity1"><a class="lineno" href="#l8" id="l8"> 8</a><span class="n">conn</span> <span class="o">=</span> <span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></div><div class="parity0"><a class="lineno" href="#l9" id="l9"> 9</a><span class="n">conn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">"GET"</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">2</span><span class="p">])</span></div><div class="parity1"><a class="lineno" href="#l10" id="l10"> 10</a><span class="n">response</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span></div><div class="parity0"><a class="lineno" href="#l11" id="l11"> 11</a><span class="k">print</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">reason</span></div><div class="parity1"><a class="lineno" href="#l12" id="l12"> 12</a><span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></div><div class="parity0"><a class="lineno" href="#l13" id="l13"> 13</a> <span class="k">if</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span></div><div class="parity1"><a class="lineno" href="#l14" id="l14"> 14</a> <span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">))</span></div><div class="parity0"><a class="lineno" href="#l15" id="l15"> 15</a><span class="k">print</span></div><div class="parity1"><a class="lineno" href="#l16" id="l16"> 16</a><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">())</span></div><div class="parity0"><a class="lineno" href="#l17" id="l17"> 17</a></div><div class="parity1"><a class="lineno" href="#l18" id="l18"> 18</a><span class="k">if</span> <span class="mf">200</span> <span class="o"><=</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o"><=</span> <span class="mf">299</span><span class="p">:</span></div><div class="parity0"><a class="lineno" href="#l19" id="l19"> 19</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">0</span><span class="p">)</span></div><div class="parity1"><a class="lineno" href="#l20" id="l20"> 20</a><span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></div> |
|
55 | 55 | </pre> |
|
56 | 56 | |
|
57 | 57 | |
|
58 | 58 | <div class="logo"> |
|
59 | 59 | <a href="http://www.selenic.com/mercurial/"> |
|
60 | 60 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> |
|
61 | 61 | </div> |
|
62 | 62 | |
|
63 | 63 | </body> |
|
64 | 64 | </html> |
|
65 | 65 | |
|
66 | % hgweb fileannotate | |
|
66 | % hgweb fileannotate, html | |
|
67 | 67 | 200 Script output follows |
|
68 | 68 | |
|
69 | 69 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
70 | 70 | <html> |
|
71 | 71 | <head> |
|
72 | 72 | <link rel="icon" href="/static/hgicon.png" type="image/png"> |
|
73 | 73 | <meta name="robots" content="index, nofollow" /> |
|
74 | 74 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> |
|
75 | 75 | |
|
76 | 76 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
77 | 77 | <title>test: get-with-headers.py annotate</title> |
|
78 | 78 | </head> |
|
79 | 79 | <body> |
|
80 | 80 | |
|
81 | 81 | <div class="buttons"> |
|
82 | 82 | <a href="/log/0">changelog</a> |
|
83 | 83 | <a href="/shortlog/0">shortlog</a> |
|
84 | 84 | <a href="/graph">graph</a> |
|
85 | 85 | <a href="/tags">tags</a> |
|
86 | 86 | <a href="/rev/79ee608ca36d">changeset</a> |
|
87 | 87 | <a href="/file/79ee608ca36d/">files</a> |
|
88 | 88 | <a href="/file/79ee608ca36d/get-with-headers.py">file</a> |
|
89 | 89 | <a href="/log/79ee608ca36d/get-with-headers.py">revisions</a> |
|
90 | 90 | <a href="/raw-annotate/79ee608ca36d/get-with-headers.py">raw</a> |
|
91 | 91 | </div> |
|
92 | 92 | |
|
93 | 93 | <h2>Annotate get-with-headers.py</h2> |
|
94 | 94 | |
|
95 | 95 | <table> |
|
96 | 96 | <tr> |
|
97 | 97 | <td class="metatag">changeset 0:</td> |
|
98 | 98 | <td><a href="/rev/79ee608ca36d">79ee608ca36d</a></td></tr> |
|
99 | 99 | |
|
100 | 100 | |
|
101 | 101 | <tr> |
|
102 | 102 | <td class="metatag">author:</td> |
|
103 | 103 | <td>test</td></tr> |
|
104 | 104 | <tr> |
|
105 | 105 | <td class="metatag">date:</td> |
|
106 | 106 | <td>Thu Jan 01 00:00:00 1970 +0000 (long ago)</td> |
|
107 | 107 | </tr> |
|
108 | 108 | <tr> |
|
109 | 109 | <td class="metatag">permissions:</td> |
|
110 | 110 | <td>-rwxr-xr-x</td> |
|
111 | 111 | </tr> |
|
112 | 112 | <tr> |
|
113 | 113 | <td class="metatag">description:</td> |
|
114 | 114 | <td>a</td> |
|
115 | 115 | </tr> |
|
116 | 116 | </table> |
|
117 | 117 | |
|
118 | 118 | <br/> |
|
119 | 119 | |
|
120 | 120 | <table cellspacing="0" cellpadding="0"> |
|
121 | 121 | <tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l1" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l1" id="l1"> 1</a></td><td><pre><span class="c">#!/usr/bin/env python</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l2" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l2" id="l2"> 2</a></td><td><pre></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l3" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l3" id="l3"> 3</a></td><td><pre><span class="n">__doc__</span> <span class="o">=</span> <span class="s">"""This does HTTP get requests given a host:port and path and returns</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l4" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l4" id="l4"> 4</a></td><td><pre><span class="s">a subset of the headers plus the body of the result."""</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l5" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l5" id="l5"> 5</a></td><td><pre></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l6" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l6" id="l6"> 6</a></td><td><pre><span class="k">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l7" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l7" id="l7"> 7</a></td><td><pre><span class="n">headers</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">3</span><span class="p">:]]</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l8" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l8" id="l8"> 8</a></td><td><pre><span class="n">conn</span> <span class="o">=</span> <span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l9" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l9" id="l9"> 9</a></td><td><pre><span class="n">conn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">"GET"</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">2</span><span class="p">])</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l10" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l10" id="l10"> 10</a></td><td><pre><span class="n">response</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l11" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l11" id="l11"> 11</a></td><td><pre><span class="k">print</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">reason</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l12" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l12" id="l12"> 12</a></td><td><pre><span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l13" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l13" id="l13"> 13</a></td><td><pre> <span class="k">if</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l14" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l14" id="l14"> 14</a></td><td><pre> <span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">))</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l15" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l15" id="l15"> 15</a></td><td><pre><span class="k">print</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l16" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l16" id="l16"> 16</a></td><td><pre><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">())</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l17" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l17" id="l17"> 17</a></td><td><pre></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l18" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l18" id="l18"> 18</a></td><td><pre><span class="k">if</span> <span class="mf">200</span> <span class="o"><=</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o"><=</span> <span class="mf">299</span><span class="p">:</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l19" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l19" id="l19"> 19</a></td><td><pre> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">0</span><span class="p">)</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l20" title="79ee608ca36d: a">test@0</a></td><td><a class="lineno" href="#l20" id="l20"> 20</a></td><td><pre><span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></pre></td></tr> |
|
122 | 122 | </table> |
|
123 | 123 | |
|
124 | 124 | |
|
125 | 125 | <div class="logo"> |
|
126 | 126 | <a href="http://www.selenic.com/mercurial/"> |
|
127 | 127 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> |
|
128 | 128 | </div> |
|
129 | 129 | |
|
130 | 130 | </body> |
|
131 | 131 | </html> |
|
132 | 132 | |
|
133 | % hgweb fileannotate, raw | |
|
134 | ||
|
135 | % hgweb filerevision, raw | |
|
136 | ||
|
133 | 137 | % hgweb highlightcss friendly |
|
134 | 138 | 200 Script output follows |
|
135 | 139 | |
|
136 | 140 | /* pygments_style = friendly */ |
|
137 | 141 | |
|
138 | 142 | % errors encountered |
|
139 | 143 | % hg serve again |
|
140 | 144 | % hgweb highlightcss fruity |
|
141 | 145 | 200 Script output follows |
|
142 | 146 | |
|
143 | 147 | /* pygments_style = fruity */ |
|
144 | 148 | |
|
145 | 149 | % errors encountered |
General Comments 0
You need to be logged in to leave comments.
Login now