diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-04 21:34:54 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-10-04 21:34:54 -0400 |
commit | a201ff9a72ed8cccedf27ef712bae00e4532b48c (patch) | |
tree | 96710bbc3b95b5e8981b8b52c07e4e57deb161fd | |
parent | 4d906d76669dcaf823c0964bda83667307bd8e2e (diff) | |
download | python-coveragepy-a201ff9a72ed8cccedf27ef712bae00e4532b48c.tar.gz |
Updated sample html report.coverage-3.1
-rw-r--r-- | doc/sample_html/_ned_py_path.html | 1508 | ||||
-rw-r--r-- | doc/sample_html/cogapp_cogapp.html | 1418 | ||||
-rw-r--r-- | doc/sample_html/cogapp_makefiles.html | 128 | ||||
-rw-r--r-- | doc/sample_html/cogapp_test_cogapp.html | 3920 | ||||
-rw-r--r-- | doc/sample_html/cogapp_whiteutils.html | 126 | ||||
-rw-r--r-- | doc/sample_html/index.html | 18 | ||||
-rw-r--r-- | doc/sample_html/style.css | 21 |
7 files changed, 4337 insertions, 2802 deletions
diff --git a/doc/sample_html/_ned_py_path.html b/doc/sample_html/_ned_py_path.html new file mode 100644 index 0000000..78637ee --- /dev/null +++ b/doc/sample_html/_ned_py_path.html @@ -0,0 +1,1508 @@ +<!doctype html PUBLIC "-//W3C//DTD html 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+<title>Coverage for c:\ned\py\path</title>
+<link rel='stylesheet' href='style.css' type='text/css'>
+<script src='jquery-1.3.2.min.js'></script>
+<script>
+function toggle_lines(btn, cls) {
+ var btn = $(btn);
+ if (btn.hasClass("hide")) {
+ $("#source ."+cls).removeClass("hide");
+ btn.removeClass("hide");
+ }
+ else {
+ $("#source ."+cls).addClass("hide");
+ btn.addClass("hide");
+ }
+}
+</script>
+</head>
+<body>
+<div id='header'>
+ <div class='content'>
+ <h1>Coverage for <b>c:\ned\py\path</b> :
+ <span class='pc_cov'>40%</span>
+ </h1>
+ <h2 class='stats'>
+ 286 statements
+ <span class='run hide' onclick='toggle_lines(this, "run")'>114 run</span>
+ <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
+ <span class='mis' onclick='toggle_lines(this, "mis")'>172 missing</span>
+ </h2>
+ </div>
+</div>
+
+<div id='source'>
+<table cellspacing='0' cellpadding='0'>
+<tr>
+<td class='linenos' valign='top'>
+<p class='pln'>1</p>
+<p class='pln'>2</p>
+<p class='pln'>3</p>
+<p class='pln'>4</p>
+<p class='pln'>5</p>
+<p class='pln'>6</p>
+<p class='pln'>7</p>
+<p class='pln'>8</p>
+<p class='pln'>9</p>
+<p class='pln'>10</p>
+<p class='pln'>11</p>
+<p class='pln'>12</p>
+<p class='pln'>13</p>
+<p class='pln'>14</p>
+<p class='pln'>15</p>
+<p class='pln'>16</p>
+<p class='pln'>17</p>
+<p class='pln'>18</p>
+<p class='pln'>19</p>
+<p class='pln'>20</p>
+<p class='pln'>21</p>
+<p class='pln'>22</p>
+<p class='pln'>23</p>
+<p class='pln'>24</p>
+<p class='pln'>25</p>
+<p class='pln'>26</p>
+<p class='pln'>27</p>
+<p class='pln'>28</p>
+<p class='pln'>29</p>
+<p class='pln'>30</p>
+<p class='pln'>31</p>
+<p class='stm run hide'>32</p>
+<p class='pln'>33</p>
+<p class='stm run hide'>34</p>
+<p class='pln'>35</p>
+<p class='stm run hide'>36</p>
+<p class='stm run hide'>37</p>
+<p class='pln'>38</p>
+<p class='pln'>39</p>
+<p class='stm run hide'>40</p>
+<p class='stm run hide'>41</p>
+<p class='stm run hide'>42</p>
+<p class='stm run hide'>43</p>
+<p class='stm mis'>44</p>
+<p class='stm mis'>45</p>
+<p class='pln'>46</p>
+<p class='pln'>47</p>
+<p class='stm run hide'>48</p>
+<p class='stm run hide'>49</p>
+<p class='stm mis'>50</p>
+<p class='stm mis'>51</p>
+<p class='pln'>52</p>
+<p class='pln'>53</p>
+<p class='stm run hide'>54</p>
+<p class='stm run hide'>55</p>
+<p class='stm run hide'>56</p>
+<p class='pln'>57</p>
+<p class='pln'>58</p>
+<p class='stm run hide'>59</p>
+<p class='pln'>60</p>
+<p class='pln'>61</p>
+<p class='pln'>62</p>
+<p class='pln'>63</p>
+<p class='pln'>64</p>
+<p class='pln'>65</p>
+<p class='pln'>66</p>
+<p class='pln'>67</p>
+<p class='stm run hide'>68</p>
+<p class='stm mis'>69</p>
+<p class='pln'>70</p>
+<p class='pln'>71</p>
+<p class='stm run hide'>72</p>
+<p class='stm mis'>73</p>
+<p class='pln'>74</p>
+<p class='stm run hide'>75</p>
+<p class='stm mis'>76</p>
+<p class='pln'>77</p>
+<p class='pln'>78</p>
+<p class='stm run hide'>79</p>
+<p class='pln'>80</p>
+<p class='pln'>81</p>
+<p class='pln'>82</p>
+<p class='pln'>83</p>
+<p class='pln'>84</p>
+<p class='stm mis'>85</p>
+<p class='pln'>86</p>
+<p class='pln'>87</p>
+<p class='stm run hide'>88</p>
+<p class='pln'>89</p>
+<p class='stm run hide'>90</p>
+<p class='pln'>91</p>
+<p class='stm mis'>92</p>
+<p class='stm run hide'>93</p>
+<p class='pln'>94</p>
+<p class='pln'>95</p>
+<p class='pln'>96</p>
+<p class='pln'>97</p>
+<p class='stm run hide'>98</p>
+<p class='stm run hide'>99</p>
+<p class='stm run hide'>100</p>
+<p class='stm run hide'>101</p>
+<p class='stm run hide'>102</p>
+<p class='stm run hide'>103</p>
+<p class='stm run hide'>104</p>
+<p class='stm run hide'>105</p>
+<p class='pln'>106</p>
+<p class='stm run hide'>107</p>
+<p class='pln'>108</p>
+<p class='pln'>109</p>
+<p class='pln'>110</p>
+<p class='pln'>111</p>
+<p class='pln'>112</p>
+<p class='pln'>113</p>
+<p class='stm mis'>114</p>
+<p class='pln'>115</p>
+<p class='stm run hide'>116</p>
+<p class='stm mis'>117</p>
+<p class='stm mis'>118</p>
+<p class='pln'>119</p>
+<p class='stm run hide'>120</p>
+<p class='stm mis'>121</p>
+<p class='stm mis'>122</p>
+<p class='pln'>123</p>
+<p class='stm run hide'>124</p>
+<p class='stm mis'>125</p>
+<p class='stm mis'>126</p>
+<p class='pln'>127</p>
+<p class='stm run hide'>128</p>
+<p class='pln'>129</p>
+<p class='pln'>130</p>
+<p class='pln'>131</p>
+<p class='pln'>132</p>
+<p class='pln'>133</p>
+<p class='pln'>134</p>
+<p class='stm run hide'>135</p>
+<p class='pln'>136</p>
+<p class='pln'>137</p>
+<p class='pln'>138</p>
+<p class='pln'>139</p>
+<p class='pln'>140</p>
+<p class='pln'>141</p>
+<p class='stm run hide'>142</p>
+<p class='pln'>143</p>
+<p class='pln'>144</p>
+<p class='pln'>145</p>
+<p class='pln'>146</p>
+<p class='pln'>147</p>
+<p class='pln'>148</p>
+<p class='pln'>149</p>
+<p class='stm run hide'>150</p>
+<p class='pln'>151</p>
+<p class='pln'>152</p>
+<p class='pln'>153</p>
+<p class='stm run hide'>154</p>
+<p class='pln'>155</p>
+<p class='pln'>156</p>
+<p class='pln'>157</p>
+<p class='pln'>158</p>
+<p class='pln'>159</p>
+<p class='stm run hide'>160</p>
+<p class='pln'>161</p>
+<p class='stm mis'>162</p>
+<p class='stm mis'>163</p>
+<p class='pln'>164</p>
+<p class='stm run hide'>165</p>
+<p class='pln'>166</p>
+<p class='pln'>167</p>
+<p class='pln'>168</p>
+<p class='pln'>169</p>
+<p class='pln'>170</p>
+<p class='pln'>171</p>
+<p class='stm mis'>172</p>
+<p class='stm mis'>173</p>
+<p class='pln'>174</p>
+<p class='stm run hide'>175</p>
+<p class='pln'>176</p>
+<p class='pln'>177</p>
+<p class='pln'>178</p>
+<p class='pln'>179</p>
+<p class='pln'>180</p>
+<p class='pln'>181</p>
+<p class='pln'>182</p>
+<p class='pln'>183</p>
+<p class='pln'>184</p>
+<p class='pln'>185</p>
+<p class='pln'>186</p>
+<p class='pln'>187</p>
+<p class='pln'>188</p>
+<p class='stm mis'>189</p>
+<p class='stm mis'>190</p>
+<p class='pln'>191</p>
+<p class='stm run hide'>192</p>
+<p class='pln'>193</p>
+<p class='pln'>194</p>
+<p class='pln'>195</p>
+<p class='pln'>196</p>
+<p class='pln'>197</p>
+<p class='stm mis'>198</p>
+<p class='pln'>199</p>
+<p class='stm run hide'>200</p>
+<p class='stm run hide'>201</p>
+<p class='stm mis'>202</p>
+<p class='stm mis'>203</p>
+<p class='pln'>204</p>
+<p class='stm run hide'>205</p>
+<p class='stm mis'>206</p>
+<p class='stm mis'>207</p>
+<p class='pln'>208</p>
+<p class='stm run hide'>209</p>
+<p class='pln'>210</p>
+<p class='pln'>211</p>
+<p class='pln'>212</p>
+<p class='pln'>213</p>
+<p class='stm run hide'>214</p>
+<p class='pln'>215</p>
+<p class='pln'>216</p>
+<p class='pln'>217</p>
+<p class='pln'>218</p>
+<p class='stm mis'>219</p>
+<p class='pln'>220</p>
+<p class='stm run hide'>221</p>
+<p class='pln'>222</p>
+<p class='pln'>223</p>
+<p class='pln'>224</p>
+<p class='pln'>225</p>
+<p class='pln'>226</p>
+<p class='pln'>227</p>
+<p class='pln'>228</p>
+<p class='pln'>229</p>
+<p class='pln'>230</p>
+<p class='stm mis'>231</p>
+<p class='stm mis'>232</p>
+<p class='stm mis'>233</p>
+<p class='stm mis'>234</p>
+<p class='stm mis'>235</p>
+<p class='stm mis'>236</p>
+<p class='stm mis'>237</p>
+<p class='stm mis'>238</p>
+<p class='stm mis'>239</p>
+<p class='stm mis'>240</p>
+<p class='stm mis'>241</p>
+<p class='pln'>242</p>
+<p class='stm run hide'>243</p>
+<p class='pln'>244</p>
+<p class='pln'>245</p>
+<p class='pln'>246</p>
+<p class='stm mis'>247</p>
+<p class='stm mis'>248</p>
+<p class='pln'>249</p>
+<p class='stm run hide'>250</p>
+<p class='pln'>251</p>
+<p class='pln'>252</p>
+<p class='pln'>253</p>
+<p class='pln'>254</p>
+<p class='pln'>255</p>
+<p class='pln'>256</p>
+<p class='stm mis'>257</p>
+<p class='stm mis'>258</p>
+<p class='pln'>259</p>
+<p class='stm mis'>260</p>
+<p class='pln'>261</p>
+<p class='stm mis'>262</p>
+<p class='pln'>263</p>
+<p class='stm mis'>264</p>
+<p class='pln'>265</p>
+<p class='stm mis'>266</p>
+<p class='pln'>267</p>
+<p class='pln'>268</p>
+<p class='stm mis'>269</p>
+<p class='stm mis'>270</p>
+<p class='stm mis'>271</p>
+<p class='stm mis'>272</p>
+<p class='stm mis'>273</p>
+<p class='pln'>274</p>
+<p class='pln'>275</p>
+<p class='pln'>276</p>
+<p class='pln'>277</p>
+<p class='stm mis'>278</p>
+<p class='pln'>279</p>
+<p class='stm mis'>280</p>
+<p class='stm mis'>281</p>
+<p class='pln'>282</p>
+<p class='stm mis'>283</p>
+<p class='pln'>284</p>
+<p class='stm mis'>285</p>
+<p class='pln'>286</p>
+<p class='pln'>287</p>
+<p class='pln'>288</p>
+<p class='pln'>289</p>
+<p class='stm run hide'>290</p>
+<p class='pln'>291</p>
+<p class='pln'>292</p>
+<p class='pln'>293</p>
+<p class='pln'>294</p>
+<p class='pln'>295</p>
+<p class='pln'>296</p>
+<p class='pln'>297</p>
+<p class='pln'>298</p>
+<p class='pln'>299</p>
+<p class='pln'>300</p>
+<p class='stm mis'>301</p>
+<p class='stm mis'>302</p>
+<p class='stm mis'>303</p>
+<p class='stm mis'>304</p>
+<p class='pln'>305</p>
+<p class='stm run hide'>306</p>
+<p class='pln'>307</p>
+<p class='pln'>308</p>
+<p class='pln'>309</p>
+<p class='pln'>310</p>
+<p class='pln'>311</p>
+<p class='pln'>312</p>
+<p class='pln'>313</p>
+<p class='pln'>314</p>
+<p class='pln'>315</p>
+<p class='pln'>316</p>
+<p class='stm mis'>317</p>
+<p class='pln'>318</p>
+<p class='stm run hide'>319</p>
+<p class='pln'>320</p>
+<p class='pln'>321</p>
+<p class='pln'>322</p>
+<p class='pln'>323</p>
+<p class='pln'>324</p>
+<p class='pln'>325</p>
+<p class='pln'>326</p>
+<p class='pln'>327</p>
+<p class='pln'>328</p>
+<p class='pln'>329</p>
+<p class='stm mis'>330</p>
+<p class='pln'>331</p>
+<p class='stm run hide'>332</p>
+<p class='pln'>333</p>
+<p class='pln'>334</p>
+<p class='pln'>335</p>
+<p class='pln'>336</p>
+<p class='pln'>337</p>
+<p class='pln'>338</p>
+<p class='pln'>339</p>
+<p class='pln'>340</p>
+<p class='pln'>341</p>
+<p class='stm mis'>342</p>
+<p class='stm mis'>343</p>
+<p class='stm mis'>344</p>
+<p class='stm mis'>345</p>
+<p class='stm mis'>346</p>
+<p class='stm mis'>347</p>
+<p class='pln'>348</p>
+<p class='stm run hide'>349</p>
+<p class='pln'>350</p>
+<p class='pln'>351</p>
+<p class='pln'>352</p>
+<p class='pln'>353</p>
+<p class='pln'>354</p>
+<p class='pln'>355</p>
+<p class='pln'>356</p>
+<p class='stm mis'>357</p>
+<p class='stm mis'>358</p>
+<p class='stm mis'>359</p>
+<p class='stm mis'>360</p>
+<p class='stm mis'>361</p>
+<p class='pln'>362</p>
+<p class='stm run hide'>363</p>
+<p class='pln'>364</p>
+<p class='pln'>365</p>
+<p class='pln'>366</p>
+<p class='pln'>367</p>
+<p class='pln'>368</p>
+<p class='pln'>369</p>
+<p class='pln'>370</p>
+<p class='stm mis'>371</p>
+<p class='stm mis'>372</p>
+<p class='stm mis'>373</p>
+<p class='stm mis'>374</p>
+<p class='stm mis'>375</p>
+<p class='stm mis'>376</p>
+<p class='stm mis'>377</p>
+<p class='pln'>378</p>
+<p class='stm run hide'>379</p>
+<p class='pln'>380</p>
+<p class='pln'>381</p>
+<p class='pln'>382</p>
+<p class='pln'>383</p>
+<p class='pln'>384</p>
+<p class='stm mis'>385</p>
+<p class='pln'>386</p>
+<p class='stm run hide'>387</p>
+<p class='pln'>388</p>
+<p class='pln'>389</p>
+<p class='pln'>390</p>
+<p class='pln'>391</p>
+<p class='pln'>392</p>
+<p class='pln'>393</p>
+<p class='pln'>394</p>
+<p class='stm mis'>395</p>
+<p class='pln'>396</p>
+<p class='pln'>397</p>
+<p class='pln'>398</p>
+<p class='pln'>399</p>
+<p class='stm run hide'>400</p>
+<p class='pln'>401</p>
+<p class='stm mis'>402</p>
+<p class='pln'>403</p>
+<p class='stm run hide'>404</p>
+<p class='pln'>405</p>
+<p class='stm mis'>406</p>
+<p class='stm mis'>407</p>
+<p class='stm mis'>408</p>
+<p class='pln'>409</p>
+<p class='stm mis'>410</p>
+<p class='pln'>411</p>
+<p class='stm run hide'>412</p>
+<p class='pln'>413</p>
+<p class='pln'>414</p>
+<p class='pln'>415</p>
+<p class='pln'>416</p>
+<p class='pln'>417</p>
+<p class='stm mis'>418</p>
+<p class='stm mis'>419</p>
+<p class='pln'>420</p>
+<p class='stm mis'>421</p>
+<p class='stm mis'>422</p>
+<p class='stm mis'>423</p>
+<p class='stm mis'>424</p>
+<p class='pln'>425</p>
+<p class='stm mis'>426</p>
+<p class='pln'>427</p>
+<p class='stm run hide'>428</p>
+<p class='pln'>429</p>
+<p class='pln'>430</p>
+<p class='pln'>431</p>
+<p class='pln'>432</p>
+<p class='pln'>433</p>
+<p class='pln'>434</p>
+<p class='pln'>435</p>
+<p class='pln'>436</p>
+<p class='pln'>437</p>
+<p class='pln'>438</p>
+<p class='pln'>439</p>
+<p class='pln'>440</p>
+<p class='pln'>441</p>
+<p class='pln'>442</p>
+<p class='stm mis'>443</p>
+<p class='pln'>444</p>
+<p class='stm mis'>445</p>
+<p class='stm mis'>446</p>
+<p class='stm mis'>447</p>
+<p class='pln'>448</p>
+<p class='stm mis'>449</p>
+<p class='pln'>450</p>
+<p class='pln'>451</p>
+<p class='stm mis'>452</p>
+<p class='pln'>453</p>
+<p class='pln'>454</p>
+<p class='stm mis'>455</p>
+<p class='stm mis'>456</p>
+<p class='pln'>457</p>
+<p class='stm mis'>458</p>
+<p class='stm mis'>459</p>
+<p class='pln'>460</p>
+<p class='stm run hide'>461</p>
+<p class='pln'>462</p>
+<p class='pln'>463</p>
+<p class='pln'>464</p>
+<p class='pln'>465</p>
+<p class='pln'>466</p>
+<p class='pln'>467</p>
+<p class='pln'>468</p>
+<p class='pln'>469</p>
+<p class='pln'>470</p>
+<p class='pln'>471</p>
+<p class='pln'>472</p>
+<p class='pln'>473</p>
+<p class='pln'>474</p>
+<p class='pln'>475</p>
+<p class='pln'>476</p>
+<p class='pln'>477</p>
+<p class='pln'>478</p>
+<p class='pln'>479</p>
+<p class='pln'>480</p>
+<p class='pln'>481</p>
+<p class='pln'>482</p>
+<p class='pln'>483</p>
+<p class='pln'>484</p>
+<p class='pln'>485</p>
+<p class='pln'>486</p>
+<p class='pln'>487</p>
+<p class='pln'>488</p>
+<p class='pln'>489</p>
+<p class='pln'>490</p>
+<p class='pln'>491</p>
+<p class='pln'>492</p>
+<p class='pln'>493</p>
+<p class='pln'>494</p>
+<p class='stm mis'>495</p>
+<p class='stm mis'>496</p>
+<p class='stm mis'>497</p>
+<p class='stm mis'>498</p>
+<p class='stm mis'>499</p>
+<p class='stm mis'>500</p>
+<p class='pln'>501</p>
+<p class='stm mis'>502</p>
+<p class='stm mis'>503</p>
+<p class='pln'>504</p>
+<p class='stm mis'>505</p>
+<p class='stm mis'>506</p>
+<p class='stm mis'>507</p>
+<p class='stm mis'>508</p>
+<p class='pln'>509</p>
+<p class='stm mis'>510</p>
+<p class='pln'>511</p>
+<p class='stm run hide'>512</p>
+<p class='pln'>513</p>
+<p class='pln'>514</p>
+<p class='pln'>515</p>
+<p class='pln'>516</p>
+<p class='pln'>517</p>
+<p class='pln'>518</p>
+<p class='pln'>519</p>
+<p class='pln'>520</p>
+<p class='pln'>521</p>
+<p class='pln'>522</p>
+<p class='pln'>523</p>
+<p class='pln'>524</p>
+<p class='pln'>525</p>
+<p class='pln'>526</p>
+<p class='pln'>527</p>
+<p class='pln'>528</p>
+<p class='stm mis'>529</p>
+<p class='stm mis'>530</p>
+<p class='stm mis'>531</p>
+<p class='stm mis'>532</p>
+<p class='pln'>533</p>
+<p class='stm mis'>534</p>
+<p class='pln'>535</p>
+<p class='stm mis'>536</p>
+<p class='pln'>537</p>
+<p class='stm run hide'>538</p>
+<p class='pln'>539</p>
+<p class='pln'>540</p>
+<p class='pln'>541</p>
+<p class='pln'>542</p>
+<p class='pln'>543</p>
+<p class='pln'>544</p>
+<p class='pln'>545</p>
+<p class='pln'>546</p>
+<p class='pln'>547</p>
+<p class='pln'>548</p>
+<p class='pln'>549</p>
+<p class='stm mis'>550</p>
+<p class='stm mis'>551</p>
+<p class='stm mis'>552</p>
+<p class='stm mis'>553</p>
+<p class='stm mis'>554</p>
+<p class='stm mis'>555</p>
+<p class='stm mis'>556</p>
+<p class='stm mis'>557</p>
+<p class='stm mis'>558</p>
+<p class='stm mis'>559</p>
+<p class='pln'>560</p>
+<p class='stm mis'>561</p>
+<p class='pln'>562</p>
+<p class='pln'>563</p>
+<p class='pln'>564</p>
+<p class='pln'>565</p>
+<p class='stm run hide'>566</p>
+<p class='stm run hide'>567</p>
+<p class='stm run hide'>568</p>
+<p class='stm run hide'>569</p>
+<p class='stm run hide'>570</p>
+<p class='stm run hide'>571</p>
+<p class='pln'>572</p>
+<p class='stm run hide'>573</p>
+<p class='stm mis'>574</p>
+<p class='pln'>575</p>
+<p class='stm run hide'>576</p>
+<p class='stm run hide'>577</p>
+<p class='pln'>578</p>
+<p class='pln'>579</p>
+<p class='pln'>580</p>
+<p class='stm run hide'>581</p>
+<p class='stm run hide'>582</p>
+<p class='pln'>583</p>
+<p class='pln'>584</p>
+<p class='pln'>585</p>
+<p class='stm run hide'>586</p>
+<p class='stm run hide'>587</p>
+<p class='stm run hide'>588</p>
+<p class='pln'>589</p>
+<p class='pln'>590</p>
+<p class='pln'>591</p>
+<p class='stm run hide'>592</p>
+<p class='stm run hide'>593</p>
+<p class='pln'>594</p>
+<p class='pln'>595</p>
+<p class='pln'>596</p>
+<p class='stm run hide'>597</p>
+<p class='stm run hide'>598</p>
+<p class='pln'>599</p>
+<p class='pln'>600</p>
+<p class='pln'>601</p>
+<p class='pln'>602</p>
+<p class='stm mis'>603</p>
+<p class='pln'>604</p>
+<p class='stm run hide'>605</p>
+<p class='pln'>606</p>
+<p class='stm mis'>607</p>
+<p class='pln'>608</p>
+<p class='stm run hide'>609</p>
+<p class='pln'>610</p>
+<p class='stm mis'>611</p>
+<p class='pln'>612</p>
+<p class='stm run hide'>613</p>
+<p class='stm mis'>614</p>
+<p class='pln'>615</p>
+<p class='stm mis'>616</p>
+<p class='pln'>617</p>
+<p class='stm run hide'>618</p>
+<p class='stm mis'>619</p>
+<p class='stm mis'>620</p>
+<p class='pln'>621</p>
+<p class='pln'>622</p>
+<p class='pln'>623</p>
+<p class='pln'>624</p>
+<p class='stm run hide'>625</p>
+<p class='pln'>626</p>
+<p class='stm mis'>627</p>
+<p class='pln'>628</p>
+<p class='stm run hide'>629</p>
+<p class='stm mis'>630</p>
+<p class='pln'>631</p>
+<p class='stm run hide'>632</p>
+<p class='stm mis'>633</p>
+<p class='stm mis'>634</p>
+<p class='pln'>635</p>
+<p class='stm run hide'>636</p>
+<p class='stm mis'>637</p>
+<p class='pln'>638</p>
+<p class='stm run hide'>639</p>
+<p class='stm mis'>640</p>
+<p class='pln'>641</p>
+<p class='pln'>642</p>
+<p class='pln'>643</p>
+<p class='pln'>644</p>
+<p class='stm run hide'>645</p>
+<p class='stm mis'>646</p>
+<p class='pln'>647</p>
+<p class='stm run hide'>648</p>
+<p class='stm mis'>649</p>
+<p class='pln'>650</p>
+<p class='stm run hide'>651</p>
+<p class='stm mis'>652</p>
+<p class='pln'>653</p>
+<p class='stm run hide'>654</p>
+<p class='stm mis'>655</p>
+<p class='pln'>656</p>
+<p class='pln'>657</p>
+<p class='pln'>658</p>
+<p class='pln'>659</p>
+<p class='stm run hide'>660</p>
+<p class='pln'>661</p>
+<p class='pln'>662</p>
+<p class='pln'>663</p>
+<p class='stm mis'>664</p>
+<p class='stm mis'>665</p>
+<p class='stm mis'>666</p>
+<p class='pln'>667</p>
+<p class='stm run hide'>668</p>
+<p class='stm mis'>669</p>
+<p class='pln'>670</p>
+<p class='stm run hide'>671</p>
+<p class='stm mis'>672</p>
+<p class='pln'>673</p>
+<p class='pln'>674</p>
+<p class='pln'>675</p>
+<p class='pln'>676</p>
+<p class='stm run hide'>677</p>
+<p class='stm mis'>678</p>
+<p class='pln'>679</p>
+<p class='stm mis'>680</p>
+<p class='pln'>681</p>
+<p class='stm run hide'>682</p>
+<p class='stm mis'>683</p>
+<p class='pln'>684</p>
+<p class='stm mis'>685</p>
+<p class='pln'>686</p>
+<p class='stm run hide'>687</p>
+<p class='stm mis'>688</p>
+<p class='pln'>689</p>
+<p class='pln'>690</p>
+<p class='pln'>691</p>
+<p class='pln'>692</p>
+<p class='stm mis'>693</p>
+<p class='pln'>694</p>
+<p class='stm mis'>695</p>
+<p class='pln'>696</p>
+<p class='pln'>697</p>
+<p class='pln'>698</p>
+<p class='pln'>699</p>
+<p class='stm mis'>700</p>
+<p class='stm mis'>701</p>
+<p class='stm mis'>702</p>
+<p class='pln'>703</p>
+<p class='stm mis'>704</p>
+<p class='pln'>705</p>
+<p class='pln'>706</p>
+<p class='pln'>707</p>
+<p class='pln'>708</p>
+<p class='stm run hide'>709</p>
+<p class='stm run hide'>710</p>
+<p class='stm run hide'>711</p>
+<p class='stm run hide'>712</p>
+<p class='stm run hide'>713</p>
+<p class='stm run hide'>714</p>
+<p class='stm run hide'>715</p>
+<p class='stm run hide'>716</p>
+<p class='stm run hide'>717</p>
+<p class='pln'>718</p>
+<p class='pln'>719</p>
+<p class='pln'>720</p>
+<p class='pln'>721</p>
+<p class='stm run hide'>722</p>
+<p class='stm mis'>723</p>
+<p class='stm mis'>724</p>
+<p class='pln'>725</p>
+<p class='stm run hide'>726</p>
+<p class='stm run hide'>727</p>
+<p class='stm mis'>728</p>
+<p class='pln'>729</p>
+
+</td>
+<td class='text' valign='top'>
+<p class='pln'><span class='str'>""" path.py - An object representing a path to a file or directory.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>Example:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>from path import path</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>d = path('/home/guido/bin')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>for f in d.files('*.py'):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> f.chmod(0755)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>This module requires Python 2.2 or later.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>URL: http://www.jorendorff.com/articles/python/path</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>Author: Jason Orendorff <jason@jorendorff.com> (and others - see the url!)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>Date: 29 Feb 2004</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>"""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># TODO</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Bug in write_text(). It doesn't support Universal newline mode.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Better error message in listdir() when self isn't a</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># directory. (On Windows, the error message really sucks.)</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Make sure everything has a good docstring.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Add methods for regex find and replace.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - guess_content_type() method?</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Perhaps support arguments to touch().</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Could add split() and join() methods that generate warnings.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - Note: __add__() technically has a bug, I think, where</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># it doesn't play nice with other types that implement</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># __radd__(). Test this.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>__future__</span> <span class='key'>import</span> <span class='nam'>generators</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>sys</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>,</span> <span class='nam'>fnmatch</span><span class='op'>,</span> <span class='nam'>glob</span><span class='op'>,</span> <span class='nam'>shutil</span><span class='op'>,</span> <span class='nam'>codecs</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>__version__</span> <span class='op'>=</span> <span class='str'>'2.0.2'</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>__all__</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'path'</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Pre-2.3 support. Are unicode filenames supported?</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>_base</span> <span class='op'>=</span> <span class='nam'>str</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>supports_unicode_filenames</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>_base</span> <span class='op'>=</span> <span class='nam'>unicode</span><span class="strut"> </span></p>
+<p class='stm mis'><span class='key'>except</span> <span class='nam'>AttributeError</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>pass</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Pre-2.3 workaround for basestring.</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>basestring</span><span class="strut"> </span></p>
+<p class='stm mis'><span class='key'>except</span> <span class='nam'>NameError</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>basestring</span> <span class='op'>=</span> <span class='op'>(</span><span class='nam'>str</span><span class='op'>,</span> <span class='nam'>unicode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Universal newline support</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>_textmode</span> <span class='op'>=</span> <span class='str'>'r'</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>file</span><span class='op'>,</span> <span class='str'>'newlines'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>_textmode</span> <span class='op'>=</span> <span class='str'>'U'</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>_base</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Represents a filesystem path.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> For documentation on individual methods, consult their</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> counterparts in os.path.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Special Python methods.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='str'>'path(%s)'</span> <span class='op'>%</span> <span class='nam'>_base</span><span class='op'>.</span><span class='nam'>__repr__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Adding a path and a string yields a path.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__add__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>more</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>_base</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span> <span class='op'>+</span> <span class='nam'>more</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__radd__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>other</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>other</span> <span class='op'>+</span> <span class='nam'>_base</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># The / operator joins paths.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__div__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>rel</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" fp.__div__(rel) == fp / rel == fp.joinpath(rel)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Join two path components, adding a separator character if</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> needed.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>rel</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Make the / operator work even when true division is enabled.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>__truediv__</span> <span class='op'>=</span> <span class='nam'>__div__</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>getcwd</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return the current working directory as a path object. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>getcwd</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>getcwd</span> <span class='op'>=</span> <span class='nam'>staticmethod</span><span class='op'>(</span><span class='nam'>getcwd</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Operations on path strings.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>abspath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>abspath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>normcase</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>normcase</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>normpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>normpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>realpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>realpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>expanduser</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>expanduser</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>expandvars</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>expandvars</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>dirname</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>dirname</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>basename</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>basename</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>expand</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Clean up a filename by calling expandvars(),</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> expanduser(), and normpath() on it.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is commonly everything needed to clean up a filename</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> read from a configuration file, for example.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>expandvars</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>expanduser</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>normpath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>_get_namebase</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>base</span><span class='op'>,</span> <span class='nam'>ext</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitext</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>base</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>_get_ext</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>,</span> <span class='nam'>ext</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitext</span><span class='op'>(</span><span class='nam'>_base</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>ext</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>_get_drive</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>drive</span><span class='op'>,</span> <span class='nam'>r</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitdrive</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>drive</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>parent</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>dirname</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" This path's parent directory, as a new path object.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> For example, path('/usr/local/lib/libpython.so').parent == path('/usr/local/lib')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>name</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>basename</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The name of this file or directory without the full path.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> For example, path('/usr/local/lib/libpython.so').name == 'libpython.so'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>namebase</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>_get_namebase</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The same as path.name, but with one file extension stripped off.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> For example, path('/home/guido/python.tar.gz').name == 'python.tar.gz',</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> but path('/home/guido/python.tar.gz').namebase == 'python.tar'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>ext</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>_get_ext</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The file extension, for example '.py'. """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>drive</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>_get_drive</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The drive specifier, for example 'C:'.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is always empty on systems that don't use drive specifiers.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>splitpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" p.splitpath() -> Return (p.parent, p.name). """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>parent</span><span class='op'>,</span> <span class='nam'>child</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>parent</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>child</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>splitdrive</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" p.splitdrive() -> Return (p.drive, <the rest of p>).</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Split the drive specifier from this path. If there is</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> no drive specifier, p.drive is empty, so the return value</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> is simply (path(''), p). This is always the case on Unix.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>drive</span><span class='op'>,</span> <span class='nam'>rel</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitdrive</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>drive</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>rel</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>splitext</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" p.splitext() -> Return (p.stripext(), p.ext).</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Split the filename extension from this path and return</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> the two parts. Either part may be empty.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The extension is everything from '.' to the end of the</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last path segment. This has the property that if</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> (a, b) == p.splitext(), then a + b == p.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Cast to plain string using _base because Python 2.2</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># implementations of os.path.splitext use "for c in path:..."</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># which means something different when applied to a path</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># object.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>filename</span><span class='op'>,</span> <span class='nam'>ext</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitext</span><span class='op'>(</span><span class='nam'>_base</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>filename</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>ext</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>stripext</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" p.stripext() -> Remove one file extension from the path.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> For example, path('/home/guido/python.tar.gz').stripext()</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> returns path('/home/guido/python.tar').</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>splitext</span><span class='op'>(</span><span class='op'>)</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>,</span> <span class='str'>'splitunc'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>splitunc</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>unc</span><span class='op'>,</span> <span class='nam'>rest</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitunc</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>unc</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>rest</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>_get_uncshare</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>unc</span><span class='op'>,</span> <span class='nam'>r</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>splitunc</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>unc</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>uncshare</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>_get_uncshare</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The UNC mount point for this path.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is empty for paths on local drives. """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>joinpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Join two or more path components, adding a separator</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> character (os.sep) if needed. Returns a new path</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> object.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>splitall</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return a list of the path components in this path.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The first item in the list will be a path. Its value will be</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> either os.curdir, os.pardir, empty, or the root directory of</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> this path (for example, '/' or 'C:\\'). The other items in</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> the list will be strings.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> path.path.joinpath(*result) will yield the original path.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>parts</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>loc</span> <span class='op'>=</span> <span class='nam'>self</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>while</span> <span class='nam'>loc</span> <span class='op'>!=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>curdir</span> <span class='key'>and</span> <span class='nam'>loc</span> <span class='op'>!=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>pardir</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>prev</span> <span class='op'>=</span> <span class='nam'>loc</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>loc</span><span class='op'>,</span> <span class='nam'>child</span> <span class='op'>=</span> <span class='nam'>prev</span><span class='op'>.</span><span class='nam'>splitpath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>loc</span> <span class='op'>==</span> <span class='nam'>prev</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>break</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>parts</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>child</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>parts</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>loc</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>parts</span><span class='op'>.</span><span class='nam'>reverse</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>parts</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>relpath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return this path as a relative path,</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> based from the current working directory.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>cwd</span> <span class='op'>=</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>getcwd</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>cwd</span><span class='op'>.</span><span class='nam'>relpathto</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>relpathto</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dest</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return a relative path from self to dest.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> If there is no relative path from self to dest, for example if</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> they reside on different drives in Windows, then this returns</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> dest.abspath().</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>origin</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>abspath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>dest</span> <span class='op'>=</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>dest</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>abspath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>orig_list</span> <span class='op'>=</span> <span class='nam'>origin</span><span class='op'>.</span><span class='nam'>normcase</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>splitall</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Don't normcase dest! We want to preserve the case.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>dest_list</span> <span class='op'>=</span> <span class='nam'>dest</span><span class='op'>.</span><span class='nam'>splitall</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>orig_list</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span> <span class='op'>!=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>normcase</span><span class='op'>(</span><span class='nam'>dest_list</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Can't get here from there.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>dest</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Find the location where the two paths start to differ.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>i</span> <span class='op'>=</span> <span class='num'>0</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>start_seg</span><span class='op'>,</span> <span class='nam'>dest_seg</span> <span class='key'>in</span> <span class='nam'>zip</span><span class='op'>(</span><span class='nam'>orig_list</span><span class='op'>,</span> <span class='nam'>dest_list</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>start_seg</span> <span class='op'>!=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>normcase</span><span class='op'>(</span><span class='nam'>dest_seg</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>break</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>i</span> <span class='op'>+=</span> <span class='num'>1</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Now i is the point where the two paths diverge.</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Need a certain number of "os.pardir"s to work up</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># from the origin to the point of divergence.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>segments</span> <span class='op'>=</span> <span class='op'>[</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>pardir</span><span class='op'>]</span> <span class='op'>*</span> <span class='op'>(</span><span class='nam'>len</span><span class='op'>(</span><span class='nam'>orig_list</span><span class='op'>)</span> <span class='op'>-</span> <span class='nam'>i</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Need to add the diverging part of dest_list.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>segments</span> <span class='op'>+=</span> <span class='nam'>dest_list</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>:</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>segments</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If they happen to be identical, use os.curdir.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>curdir</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>segments</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Listing, searching, walking, and matching</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>listdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" D.listdir() -> List of items in this directory.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Use D.files() or D.dirs() instead if you want a listing</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> of just files or just subdirectories.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The elements of the list are path objects.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> With the optional 'pattern' argument, this only lists</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> items whose names match the given pattern.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>names</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>listdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>pattern</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>names</span> <span class='op'>=</span> <span class='nam'>fnmatch</span><span class='op'>.</span><span class='nam'>filter</span><span class='op'>(</span><span class='nam'>names</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='op'>[</span><span class='nam'>self</span> <span class='op'>/</span> <span class='nam'>child</span> <span class='key'>for</span> <span class='nam'>child</span> <span class='key'>in</span> <span class='nam'>names</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>dirs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" D.dirs() -> List of this directory's subdirectories.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The elements of the list are path objects.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This does not walk recursively into subdirectories</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> (but see path.walkdirs).</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> With the optional 'pattern' argument, this only lists</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> directories whose names match the given pattern. For</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> example, d.dirs('build-*').</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='op'>[</span><span class='nam'>p</span> <span class='key'>for</span> <span class='nam'>p</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>listdir</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span> <span class='key'>if</span> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>isdir</span><span class='op'>(</span><span class='op'>)</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>files</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" D.files() -> List of the files in this directory.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The elements of the list are path objects.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This does not walk into subdirectories (see path.walkfiles).</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> With the optional 'pattern' argument, this only lists files</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> whose names match the given pattern. For example,</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> d.files('*.pyc').</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='op'>[</span><span class='nam'>p</span> <span class='key'>for</span> <span class='nam'>p</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>listdir</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span> <span class='key'>if</span> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>isfile</span><span class='op'>(</span><span class='op'>)</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>walk</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" D.walk() -> iterator over files and subdirs, recursively.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The iterator yields path objects naming each child item of</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> this directory and its descendants. This requires that</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> D.isdir().</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This performs a depth-first traversal of the directory tree.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Each directory is returned just before all its children.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>child</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>listdir</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>pattern</span> <span class='key'>is</span> <span class='nam'>None</span> <span class='key'>or</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>fnmatch</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>yield</span> <span class='nam'>child</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>isdir</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>item</span> <span class='key'>in</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>walk</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>yield</span> <span class='nam'>item</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>walkdirs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" D.walkdirs() -> iterator over subdirs, recursively.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> With the optional 'pattern' argument, this yields only</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> directories whose names match the given pattern. For</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> example, mydir.walkdirs('*test') yields only directories</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> with names ending in 'test'.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>child</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>dirs</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>pattern</span> <span class='key'>is</span> <span class='nam'>None</span> <span class='key'>or</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>fnmatch</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>yield</span> <span class='nam'>child</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>subsubdir</span> <span class='key'>in</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>walkdirs</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>yield</span> <span class='nam'>subsubdir</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>walkfiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" D.walkfiles() -> iterator over files in D, recursively.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The optional argument, pattern, limits the results to files</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> with names that match the pattern. For example,</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> mydir.walkfiles('*.tmp') yields only files with the .tmp</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> extension.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>child</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>listdir</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>isfile</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>pattern</span> <span class='key'>is</span> <span class='nam'>None</span> <span class='key'>or</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>fnmatch</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>yield</span> <span class='nam'>child</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>isdir</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>f</span> <span class='key'>in</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>walkfiles</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>yield</span> <span class='nam'>f</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>fnmatch</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return True if self.name matches the given pattern.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> pattern - A filename pattern with wildcards,</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for example '*.py'.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>fnmatch</span><span class='op'>.</span><span class='nam'>fnmatch</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>glob</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>pattern</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return a list of path objects that match the pattern.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> pattern - a path relative to this directory, with wildcards.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> For example, path('/users').glob('*/bin/*') returns a list</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> of all the files users have in their bin directories.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>map</span><span class='op'>(</span><span class='nam'>path</span><span class='op'>,</span> <span class='nam'>glob</span><span class='op'>.</span><span class='nam'>glob</span><span class='op'>(</span><span class='nam'>_base</span><span class='op'>(</span><span class='nam'>self</span> <span class='op'>/</span> <span class='nam'>pattern</span><span class='op'>)</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Reading or writing an entire file at once.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>=</span><span class='str'>'r'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Open this file. Return a file object. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>file</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>bytes</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Open this file, read all bytes, return them as a string. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='str'>'rb'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>read</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>write_bytes</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>bytes</span><span class='op'>,</span> <span class='nam'>append</span><span class='op'>=</span><span class='nam'>False</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Open this file and write the given bytes to it.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Default behavior is to overwrite any existing file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Call this with write_bytes(bytes, append=True) to append instead.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>append</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>mode</span> <span class='op'>=</span> <span class='str'>'ab'</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>mode</span> <span class='op'>=</span> <span class='str'>'wb'</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>bytes</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>text</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>encoding</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>=</span><span class='str'>'strict'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Open this file, read it in, return the content as a string.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This uses 'U' mode in Python 2.3 and later, so '\r\n' and '\r'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> are automatically translated to '\n'.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Optional arguments:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> encoding - The Unicode encoding (or character set) of</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> the file. If present, the content of the file is</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> decoded and returned as a unicode object; otherwise</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> it is returned as an 8-bit str.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> errors - How to handle Unicode errors; see help(str.decode)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for the options. Default is 'strict'.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>encoding</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># 8-bit</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>_textmode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>read</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Unicode</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>codecs</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='str'>'r'</span><span class='op'>,</span> <span class='nam'>encoding</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># (Note - Can't use 'U' mode here, since codecs.open</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># doesn't support 'U' mode, even in Python 2.3.)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>t</span> <span class='op'>=</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>read</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>t</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='str'>u'\r\n'</span><span class='op'>,</span> <span class='str'>u'\n'</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='str'>u'\r'</span><span class='op'>,</span> <span class='str'>u'\n'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>write_text</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>text</span><span class='op'>,</span> <span class='nam'>encoding</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>=</span><span class='str'>'strict'</span><span class='op'>,</span> <span class='nam'>append</span><span class='op'>=</span><span class='nam'>False</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Write the given text to this file.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The default behavior is to overwrite any existing file;</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> to append instead, use the 'append=True' keyword argument.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> There are two differences between path.write_text() and</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> path.write_bytes(): Unicode handling and newline handling.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --- Unicode</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> If 'text' isn't Unicode, this essentially just does</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> open(self, 'w').write(text). The 'encoding' and 'errors'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> arguments are ignored.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> If 'text' is Unicode, it is first converted to bytes using the</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> specified 'encoding' (or the default encoding if 'encoding'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> isn't specified). The 'errors' argument applies only to this</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> conversion.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --- Newlines</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> write_text() converts from programmer-friendly newlines</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> (always '\n') to platform-specific newlines (see os.linesep;</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> on Windows, for example, the end-of-line marker is '\r\n').</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This applies to Unicode text the same as to 8-bit text.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Because of this conversion, the text should only contain plain</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> newlines ('\n'), just like the return value of path.text().</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> If the text contains the characters '\r\n', it may be written</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> as '\r\r\n' or '\r\r' depending on your platform. (This is</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> exactly the same as when you open a file for writing with</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fopen(filename, "w") in C or file(filename, 'w') in Python.)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>text</span><span class='op'>,</span> <span class='nam'>unicode</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>text</span> <span class='op'>=</span> <span class='nam'>text</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='str'>u'\n'</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>linesep</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>encoding</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>encoding</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>getdefaultencoding</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>bytes</span> <span class='op'>=</span> <span class='nam'>text</span><span class='op'>.</span><span class='nam'>encode</span><span class='op'>(</span><span class='nam'>encoding</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>write_bytes</span><span class='op'>(</span><span class='nam'>bytes</span><span class='op'>,</span> <span class='nam'>append</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>append</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>mode</span> <span class='op'>=</span> <span class='str'>'a'</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>mode</span> <span class='op'>=</span> <span class='str'>'w'</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>text</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>lines</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>encoding</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>=</span><span class='str'>'strict'</span><span class='op'>,</span> <span class='nam'>retain</span><span class='op'>=</span><span class='nam'>True</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Open this file, read all lines, return them in a list.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Optional arguments:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> encoding - The Unicode encoding (or character set) of</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> the file. The default is None, meaning the content</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> of the file is read as 8-bit characters and returned</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> as a list of (non-Unicode) str objects.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> errors - How to handle Unicode errors; see help(str.decode)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for the options. Default is 'strict'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> retain - If true, retain newline characters; but all newline</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> character combinations ('\r', '\n', '\r\n') are</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> translated to '\n'. If false, newline characters are</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> stripped off. Default is True.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This uses 'U' mode in Python 2.3 and later.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>encoding</span> <span class='key'>is</span> <span class='nam'>None</span> <span class='key'>and</span> <span class='nam'>retain</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>_textmode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>readlines</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>text</span><span class='op'>(</span><span class='nam'>encoding</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>splitlines</span><span class='op'>(</span><span class='nam'>retain</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>write_lines</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>lines</span><span class='op'>,</span> <span class='nam'>encoding</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>=</span><span class='str'>'strict'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>linesep</span><span class='op'>=</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>linesep</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Overwrite this file with the given lines of text.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> lines - A list of strings.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> encoding - A Unicode encoding to use. This applies only if</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> 'lines' contains any Unicode strings.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> errors - How to handle errors in Unicode encoding. This</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> also applies only to Unicode strings.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> linesep - A character sequence that will be added at the</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> end of every line that doesn't already have it.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='str'>'wb'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>line</span> <span class='key'>in</span> <span class='nam'>lines</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>line</span><span class='op'>.</span><span class='nam'>endswith</span><span class='op'>(</span><span class='nam'>linesep</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>line</span> <span class='op'>+=</span> <span class='nam'>linesep</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>line</span><span class='op'>,</span> <span class='nam'>unicode</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>encoding</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>encoding</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>getdefaultencoding</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>line</span> <span class='op'>=</span> <span class='nam'>line</span><span class='op'>.</span><span class='nam'>encode</span><span class='op'>(</span><span class='nam'>encoding</span><span class='op'>,</span> <span class='nam'>errors</span><span class='op'>=</span><span class='nam'>errors</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>line</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Methods for querying the filesystem.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>exists</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>exists</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>isabs</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>isabs</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>isdir</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>isdir</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>isfile</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>isfile</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>islink</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>islink</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>ismount</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>ismount</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>,</span> <span class='str'>'samefile'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>samefile</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>samefile</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>getatime</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>getatime</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>atime</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>getatime</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Last access time of the file. """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>getmtime</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>getmtime</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>mtime</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>getmtime</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Last-modified time of the file. """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>,</span> <span class='str'>'getctime'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>getctime</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>getctime</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>ctime</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>getctime</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Creation time of the file. """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>getsize</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>getsize</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>size</span> <span class='op'>=</span> <span class='nam'>property</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>getsize</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Size of the file, in bytes. """</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'access'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return true if current user has access to this path.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> mode - One of the constants os.F_OK, os.R_OK, os.W_OK, os.X_OK</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>stat</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Perform a stat() system call on this path. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>stat</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>lstat</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Like path.stat(), but do not follow symbolic links. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>lstat</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'statvfs'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>statvfs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Perform a statvfs() system call on this path. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>statvfs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'pathconf'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>pathconf</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>pathconf</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Modifying operations on files and directories</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>utime</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>times</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Set the access and modified times of this file. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>utime</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>times</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>chmod</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>chmod</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'chown'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>chown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>uid</span><span class='op'>,</span> <span class='nam'>gid</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>chown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>uid</span><span class='op'>,</span> <span class='nam'>gid</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>rename</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>new</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>rename</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>new</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>renames</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>new</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>renames</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>new</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Create/delete operations on directories</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>mkdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>=</span><span class='num'>0777</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>mkdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>makedirs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>=</span><span class='num'>0777</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>makedirs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>rmdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>rmdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>removedirs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>removedirs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Modifying operations on files</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>touch</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Set the access/modified times of this file to the current time.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Create the file if it does not exist.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fd</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>open</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>O_WRONLY</span> <span class='op'>|</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>O_CREAT</span><span class='op'>,</span> <span class='num'>0666</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='nam'>fd</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>utime</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>None</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>remove</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>remove</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>unlink</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>unlink</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Links</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'link'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>link</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>newpath</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Create a hard link at 'newpath', pointing to this file. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>link</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>newpath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'symlink'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>symlink</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>newlink</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Create a symbolic link at 'newlink', pointing here. """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>symlink</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>newlink</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'readlink'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>readlink</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return the path to which this symbolic link points.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The result may be an absolute or a relative path.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>path</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>readlink</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>readlinkabs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Return the path to which this symbolic link points.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> The result is always an absolute path.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>readlink</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>isabs</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>p</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>parent</span> <span class='op'>/</span> <span class='nam'>p</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>abspath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- High-level functions from shutil</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>copyfile</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>copyfile</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>copymode</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>copymode</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>copystat</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>copystat</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>copy</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>copy</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>copy2</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>copy2</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>copytree</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>copytree</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>shutil</span><span class='op'>,</span> <span class='str'>'move'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>move</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>move</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>rmtree</span> <span class='op'>=</span> <span class='nam'>shutil</span><span class='op'>.</span><span class='nam'>rmtree</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># --- Special stuff from os</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'chroot'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>def</span> <span class='nam'>chroot</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>chroot</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>,</span> <span class='str'>'startfile'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>startfile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>startfile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+
+</td>
+</tr>
+</table>
+</div>
+
+</body>
+</html>
diff --git a/doc/sample_html/cogapp_cogapp.html b/doc/sample_html/cogapp_cogapp.html index 6930fb5..555756f 100644 --- a/doc/sample_html/cogapp_cogapp.html +++ b/doc/sample_html/cogapp_cogapp.html @@ -749,715 +749,715 @@ function toggle_lines(btn, cls) { </td>
<td class='text' valign='top'>
-<p class='pln'>""" Cog code generation tool.</p>
-<p class='pln'> http://nedbatchelder.com/code/cog</p>
-<p class='pln'> </p>
-<p class='pln'> Copyright 2004-2009, Ned Batchelder.</p>
-<p class='pln'>"""</p>
-<p class='pln'> </p>
-<p class='stm run hide'>import copy, getopt, imp, os, re, shlex, string, sys, traceback</p>
-<p class='stm run hide'>from cStringIO import StringIO</p>
-<p class='pln'> </p>
-<p class='pln'># The recommended way to compute md5's changed in Python 2.5</p>
-<p class='stm run hide'>try:</p>
-<p class='stm run hide'> import hashlib</p>
-<p class='stm run hide'> hash_factory = hashlib.md5</p>
-<p class='stm mis'>except ImportError:</p>
-<p class='stm mis'> import md5</p>
-<p class='stm mis'> hash_factory = md5.new</p>
-<p class='pln'> </p>
-<p class='stm run hide'>__all__ = ['Cog', 'CogUsageError']</p>
-<p class='pln'> </p>
-<p class='stm run hide'>__version__ = '2.2' # History at the end of the file.</p>
-<p class='pln'> </p>
-<p class='stm run hide'>usage = """\</p>
-<p class='pln'>cog - generate code with inlined Python code.</p>
-<p class='pln'> </p>
-<p class='pln'>cog [OPTIONS] [INFILE | @FILELIST] ...</p>
-<p class='pln'> </p>
-<p class='pln'>INFILE is the name of an input file.</p>
-<p class='pln'>FILELIST is the name of a text file containing file names or</p>
-<p class='pln'> other @FILELISTs.</p>
-<p class='pln'> </p>
-<p class='pln'>OPTIONS:</p>
-<p class='pln'> -c Checksum the output to protect it against accidental change.</p>
-<p class='pln'> -d Delete the generator code from the output file.</p>
-<p class='pln'> -D name=val Define a global string available to your generator code.</p>
-<p class='pln'> -e Warn if a file has no cog code in it.</p>
-<p class='pln'> -I PATH Add PATH to the list of directories for data files and modules.</p>
-<p class='pln'> -o OUTNAME Write the output to OUTNAME.</p>
-<p class='pln'> -r Replace the input file with the output.</p>
-<p class='pln'> -s STRING Suffix all generated output lines with STRING.</p>
-<p class='pln'> -U Write the output with Unix newlines (only LF line-endings).</p>
-<p class='pln'> -w CMD Use CMD if the output file needs to be made writable.</p>
-<p class='pln'> A %s in the CMD will be filled with the filename.</p>
-<p class='pln'> -x Excise all the generated output without running the generators.</p>
-<p class='pln'> -z The [[[end]]] marker can be omitted, and is assumed at eof.</p>
-<p class='pln'> -v Print the version of cog and exit.</p>
-<p class='pln'> -h Print this help.</p>
-<p class='pln'>"""</p>
-<p class='pln'> </p>
-<p class='pln'># Other package modules</p>
-<p class='stm run hide'>from whiteutils import *</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogError(Exception):</p>
-<p class='pln'> """ Any exception raised by Cog.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def __init__(self, msg, file='', line=0):</p>
-<p class='stm run hide'> if file:</p>
-<p class='stm run hide'> Exception.__init__(self, "%s(%d): %s" % (file, line, msg))</p>
-<p class='pln'> else:</p>
-<p class='stm mis'> Exception.__init__(self, msg)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogUsageError(CogError):</p>
-<p class='pln'> """ An error in usage of command-line arguments in cog.</p>
-<p class='pln'> """</p>
-<p class='exc'> pass #pragma: no cover</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogInternalError(CogError):</p>
-<p class='pln'> """ An error in the coding of Cog. Should never happen.</p>
-<p class='pln'> """</p>
-<p class='exc'> pass #pragma: no cover</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogGeneratedError(CogError):</p>
-<p class='pln'> """ An error raised by a user's cog generator.</p>
-<p class='pln'> """</p>
-<p class='exc'> pass #pragma: no cover</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class Redirectable:</p>
-<p class='pln'> """ An object with its own stdout and stderr files.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def __init__(self):</p>
-<p class='stm run hide'> self.stdout = sys.stdout</p>
-<p class='stm run hide'> self.stderr = sys.stderr</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def setOutput(self, stdout=None, stderr=None):</p>
-<p class='pln'> """ Assign new files for standard out and/or standard error.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> if stdout:</p>
-<p class='stm run hide'> self.stdout = stdout</p>
-<p class='stm run hide'> if stderr:</p>
-<p class='stm mis'> self.stderr = stderr</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogGenerator(Redirectable):</p>
-<p class='pln'> """ A generator pulled from a source file.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def __init__(self):</p>
-<p class='stm run hide'> Redirectable.__init__(self)</p>
-<p class='stm run hide'> self.markers = []</p>
-<p class='stm run hide'> self.lines = []</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def parseMarker(self, l):</p>
-<p class='stm run hide'> self.markers.append(l)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def parseLine(self, l):</p>
-<p class='stm run hide'> self.lines.append(l.strip('\n'))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def getCode(self):</p>
-<p class='pln'> """ Extract the executable Python code from the generator.</p>
-<p class='pln'> """</p>
-<p class='pln'> # If the markers and lines all have the same prefix</p>
-<p class='pln'> # (end-of-line comment chars, for example),</p>
-<p class='pln'> # then remove it from all the lines.</p>
-<p class='stm run hide'> prefIn = commonPrefix(self.markers + self.lines)</p>
-<p class='stm run hide'> if prefIn:</p>
-<p class='stm run hide'> self.markers = [ l.replace(prefIn, '', 1) for l in self.markers ]</p>
-<p class='stm run hide'> self.lines = [ l.replace(prefIn, '', 1) for l in self.lines ]</p>
-<p class='pln'> </p>
-<p class='stm run hide'> return reindentBlock(self.lines, '')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def evaluate(self, cog, globals, fname='cog generator'):</p>
-<p class='pln'> # figure out the right whitespace prefix for the output</p>
-<p class='stm run hide'> prefOut = whitePrefix(self.markers)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> intext = self.getCode()</p>
-<p class='stm run hide'> if not intext:</p>
-<p class='stm run hide'> return ''</p>
-<p class='pln'> </p>
-<p class='pln'> # In Python 2.2, the last line has to end in a newline.</p>
-<p class='stm run hide'> intext = "import cog\n" + intext + "\n"</p>
-<p class='stm run hide'> code = compile(intext, str(fname), 'exec')</p>
-<p class='pln'> </p>
-<p class='pln'> # Make sure the "cog" module has our state.</p>
-<p class='stm run hide'> cog.cogmodule.msg = self.msg</p>
-<p class='stm run hide'> cog.cogmodule.out = self.out</p>
-<p class='stm run hide'> cog.cogmodule.outl = self.outl</p>
-<p class='stm run hide'> cog.cogmodule.error = self.error</p>
-<p class='pln'> </p>
-<p class='stm run hide'> self.outstring = ''</p>
-<p class='stm run hide'> eval(code, globals)</p>
-<p class='pln'> </p>
-<p class='pln'> # We need to make sure that the last line in the output</p>
-<p class='pln'> # ends with a newline, or it will be joined to the</p>
-<p class='pln'> # end-output line, ruining cog's idempotency.</p>
-<p class='stm run hide'> if self.outstring and self.outstring[-1] != '\n':</p>
-<p class='stm run hide'> self.outstring += '\n'</p>
-<p class='pln'> </p>
-<p class='stm run hide'> return reindentBlock(self.outstring, prefOut)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def msg(self, s):</p>
-<p class='stm mis'> print >>self.stdout, "Message: "+s</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def out(self, sOut='', dedent=False, trimblanklines=False):</p>
-<p class='pln'> """ The cog.out function.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> if trimblanklines and ('\n' in sOut):</p>
-<p class='stm run hide'> lines = sOut.split('\n')</p>
-<p class='stm run hide'> if lines[0].strip() == '':</p>
-<p class='stm run hide'> del lines[0]</p>
-<p class='stm run hide'> if lines and lines[-1].strip() == '':</p>
-<p class='stm run hide'> del lines[-1]</p>
-<p class='stm run hide'> sOut = '\n'.join(lines)+'\n'</p>
-<p class='stm run hide'> if dedent:</p>
-<p class='stm run hide'> sOut = reindentBlock(sOut)</p>
-<p class='stm run hide'> self.outstring += sOut</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def outl(self, sOut='', **kw):</p>
-<p class='pln'> """ The cog.outl function.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> self.out(sOut, **kw)</p>
-<p class='stm run hide'> self.out('\n')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def error(self, msg='Error raised by cog generator.'):</p>
-<p class='pln'> """ The cog.error function.</p>
-<p class='pln'> Instead of raising standard python errors, cog generators can use</p>
-<p class='pln'> this function. It will display the error without a scary Python</p>
-<p class='pln'> traceback.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> raise CogGeneratedError(msg)</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class NumberedFileReader:</p>
-<p class='pln'> """ A decorator for files that counts the readline()'s called.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def __init__(self, f):</p>
-<p class='stm run hide'> self.f = f</p>
-<p class='stm run hide'> self.n = 0</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def readline(self):</p>
-<p class='stm run hide'> l = self.f.readline()</p>
-<p class='stm run hide'> if l:</p>
-<p class='stm run hide'> self.n += 1</p>
-<p class='stm run hide'> return l</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def linenumber(self):</p>
-<p class='stm run hide'> return self.n</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogOptions:</p>
-<p class='pln'> """ Options for a run of cog.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def __init__(self):</p>
-<p class='pln'> # Defaults for argument values.</p>
-<p class='stm run hide'> self.args = []</p>
-<p class='stm run hide'> self.includePath = []</p>
-<p class='stm run hide'> self.defines = {}</p>
-<p class='stm run hide'> self.bShowVersion = False</p>
-<p class='stm run hide'> self.sMakeWritableCmd = None</p>
-<p class='stm run hide'> self.bReplace = False</p>
-<p class='stm run hide'> self.bNoGenerate = False</p>
-<p class='stm run hide'> self.sOutputName = None</p>
-<p class='stm run hide'> self.bWarnEmpty = False</p>
-<p class='stm run hide'> self.bHashOutput = False</p>
-<p class='stm run hide'> self.bDeleteCode = False</p>
-<p class='stm run hide'> self.bEofCanBeEnd = False</p>
-<p class='stm run hide'> self.sSuffix = None</p>
-<p class='stm run hide'> self.bNewlines = False</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def __cmp__(self, other):</p>
-<p class='pln'> """ Comparison operator for tests to use.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> return self.__dict__.__cmp__(other.__dict__)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def clone(self):</p>
-<p class='pln'> """ Make a clone of these options, for further refinement.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> return copy.deepcopy(self)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def addToIncludePath(self, dirs):</p>
-<p class='pln'> """ Add directories to the include path.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> dirs = dirs.split(os.pathsep)</p>
-<p class='stm mis'> self.includePath.extend(dirs)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def parseArgs(self, argv):</p>
-<p class='pln'> # Parse the command line arguments.</p>
-<p class='stm mis'> try:</p>
-<p class='stm mis'> opts, self.args = getopt.getopt(argv, 'cdD:eI:o:rs:Uvw:xz')</p>
-<p class='stm mis'> except getopt.error, msg:</p>
-<p class='stm mis'> raise CogUsageError(msg)</p>
-<p class='pln'> </p>
-<p class='pln'> # Handle the command line arguments.</p>
-<p class='stm mis'> for o, a in opts:</p>
-<p class='stm mis'> if o == '-c':</p>
-<p class='stm mis'> self.bHashOutput = True</p>
-<p class='stm mis'> elif o == '-d':</p>
-<p class='stm mis'> self.bDeleteCode = True</p>
-<p class='stm mis'> elif o == '-D':</p>
-<p class='stm mis'> if a.count('=') < 1:</p>
-<p class='stm mis'> raise CogUsageError("-D takes a name=value argument")</p>
-<p class='stm mis'> name, value = a.split('=', 1)</p>
-<p class='stm mis'> self.defines[name] = value</p>
-<p class='stm mis'> elif o == '-e':</p>
-<p class='stm mis'> self.bWarnEmpty = True</p>
-<p class='stm mis'> elif o == '-I':</p>
-<p class='stm mis'> self.addToIncludePath(a)</p>
-<p class='stm mis'> elif o == '-o':</p>
-<p class='stm mis'> self.sOutputName = a</p>
-<p class='stm mis'> elif o == '-r':</p>
-<p class='stm mis'> self.bReplace = True</p>
-<p class='stm mis'> elif o == '-s':</p>
-<p class='stm mis'> self.sSuffix = a</p>
-<p class='stm mis'> elif o == '-U':</p>
-<p class='stm mis'> self.bNewlines = True</p>
-<p class='stm mis'> elif o == '-v':</p>
-<p class='stm mis'> self.bShowVersion = True</p>
-<p class='stm mis'> elif o == '-w':</p>
-<p class='stm mis'> self.sMakeWritableCmd = a</p>
-<p class='stm mis'> elif o == '-x':</p>
-<p class='stm mis'> self.bNoGenerate = True</p>
-<p class='stm mis'> elif o == '-z':</p>
-<p class='stm mis'> self.bEofCanBeEnd = True</p>
-<p class='pln'> else:</p>
-<p class='pln'> # Since getopt.getopt is given a list of possible flags,</p>
-<p class='pln'> # this is an internal error.</p>
-<p class='stm mis'> raise CogInternalError("Don't understand argument %s" % o)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def validate(self):</p>
-<p class='pln'> """ Does nothing if everything is OK, raises CogError's if it's not.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> if self.bReplace and self.bDeleteCode:</p>
-<p class='stm mis'> raise CogUsageError("Can't use -d with -r (or you would delete all your source!)")</p>
-<p class='pln'> </p>
-<p class='stm mis'> if self.bReplace and self.sOutputName:</p>
-<p class='stm mis'> raise CogUsageError("Can't use -o with -r (they are opposites)")</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class Cog(Redirectable):</p>
-<p class='pln'> """ The Cog engine.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def __init__(self):</p>
-<p class='stm run hide'> Redirectable.__init__(self)</p>
-<p class='stm run hide'> self.sBeginSpec = '[[[cog'</p>
-<p class='stm run hide'> self.sEndSpec = ']]]'</p>
-<p class='stm run hide'> self.sEndOutput = '[[[end]]]'</p>
-<p class='stm run hide'> self.reEndOutput = re.compile(r'\[\[\[end]]](?P<hashsect> *\(checksum: (?P<hash>[a-f0-9]+)\))')</p>
-<p class='stm run hide'> self.sEndFormat = '[[[end]]] (checksum: %s)'</p>
-<p class='pln'> </p>
-<p class='stm run hide'> self.options = CogOptions()</p>
-<p class='stm run hide'> self.sOutputMode = 'w'</p>
-<p class='pln'> </p>
-<p class='stm run hide'> self.installCogModule()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def showWarning(self, msg):</p>
-<p class='stm mis'> print >>self.stdout, "Warning:", msg</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def isBeginSpecLine(self, s):</p>
-<p class='stm run hide'> return string.find(s, self.sBeginSpec) >= 0</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def isEndSpecLine(self, s):</p>
-<p class='stm run hide'> return string.find(s, self.sEndSpec) >= 0 and \</p>
-<p class='pln'> not self.isEndOutputLine(s)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def isEndOutputLine(self, s):</p>
-<p class='stm run hide'> return string.find(s, self.sEndOutput) >= 0</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def installCogModule(self):</p>
-<p class='pln'> """ Magic mumbo-jumbo so that imported Python modules</p>
-<p class='pln'> can say "import cog" and get our state.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> self.cogmodule = imp.new_module('cog')</p>
-<p class='stm run hide'> self.cogmodule.path = []</p>
-<p class='stm run hide'> sys.modules['cog'] = self.cogmodule</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def processFile(self, fIn, fOut, fname=None, globals=None):</p>
-<p class='pln'> """ Process an input file object to an output file object.</p>
-<p class='pln'> fIn and fOut can be file objects, or file names.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> sFileIn = fname or ''</p>
-<p class='stm run hide'> sFileOut = fname or ''</p>
-<p class='stm run hide'> fInToClose = fOutToClose = None</p>
-<p class='pln'> # Convert filenames to files.</p>
-<p class='stm run hide'> if isinstance(fIn, basestring):</p>
-<p class='pln'> # Open the input file.</p>
-<p class='stm mis'> sFileIn = fIn</p>
-<p class='stm mis'> fIn = fInToClose = open(fIn, 'r')</p>
-<p class='stm run hide'> if isinstance(fOut, basestring):</p>
-<p class='pln'> # Open the output file.</p>
-<p class='stm mis'> sFileOut = fOut</p>
-<p class='stm mis'> fOut = fOutToClose = open(fOut, self.sOutputMode)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> try:</p>
-<p class='stm run hide'> fIn = NumberedFileReader(fIn)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> bSawCog = False</p>
-<p class='pln'> </p>
-<p class='stm run hide'> self.cogmodule.inFile = sFileIn</p>
-<p class='stm run hide'> self.cogmodule.outFile = sFileOut</p>
-<p class='pln'> </p>
-<p class='pln'> # The globals dict we'll use for this file.</p>
-<p class='stm run hide'> if globals is None:</p>
-<p class='stm run hide'> globals = {}</p>
-<p class='pln'> </p>
-<p class='pln'> # If there are any global defines, put them in the globals.</p>
-<p class='stm run hide'> globals.update(self.options.defines)</p>
-<p class='pln'> </p>
-<p class='pln'> # loop over generator chunks</p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='stm run hide'> while l:</p>
-<p class='pln'> # Find the next spec begin</p>
-<p class='stm run hide'> while l and not self.isBeginSpecLine(l):</p>
-<p class='stm run hide'> if self.isEndSpecLine(l):</p>
-<p class='stm mis'> raise CogError("Unexpected '%s'" % self.sEndSpec,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='stm run hide'> if self.isEndOutputLine(l):</p>
-<p class='stm mis'> raise CogError("Unexpected '%s'" % self.sEndOutput,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='stm run hide'> fOut.write(l)</p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='stm run hide'> if not l:</p>
-<p class='stm run hide'> break</p>
-<p class='stm run hide'> if not self.options.bDeleteCode:</p>
-<p class='stm run hide'> fOut.write(l)</p>
-<p class='pln'> </p>
-<p class='pln'> # l is the begin spec</p>
-<p class='stm run hide'> gen = CogGenerator()</p>
-<p class='stm run hide'> gen.setOutput(stdout=self.stdout)</p>
-<p class='stm run hide'> gen.parseMarker(l)</p>
-<p class='stm run hide'> firstLineNum = fIn.linenumber()</p>
-<p class='stm run hide'> self.cogmodule.firstLineNum = firstLineNum</p>
-<p class='pln'> </p>
-<p class='pln'> # If the spec begin is also a spec end, then process the single</p>
-<p class='pln'> # line of code inside.</p>
-<p class='stm run hide'> if self.isEndSpecLine(l):</p>
-<p class='stm run hide'> beg = string.find(l, self.sBeginSpec)</p>
-<p class='stm run hide'> end = string.find(l, self.sEndSpec)</p>
-<p class='stm run hide'> if beg > end:</p>
-<p class='stm run hide'> raise CogError("Cog code markers inverted",</p>
-<p class='pln'> file=sFileIn, line=firstLineNum)</p>
-<p class='pln'> else:</p>
-<p class='stm run hide'> sCode = l[beg+len(self.sBeginSpec):end].strip()</p>
-<p class='stm run hide'> gen.parseLine(sCode)</p>
-<p class='pln'> else:</p>
-<p class='pln'> # Deal with an ordinary code block.</p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='pln'> </p>
-<p class='pln'> # Get all the lines in the spec</p>
-<p class='stm run hide'> while l and not self.isEndSpecLine(l):</p>
-<p class='stm run hide'> if self.isBeginSpecLine(l):</p>
-<p class='stm mis'> raise CogError("Unexpected '%s'" % self.sBeginSpec,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='stm run hide'> if self.isEndOutputLine(l):</p>
-<p class='stm mis'> raise CogError("Unexpected '%s'" % self.sEndOutput,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='stm run hide'> if not self.options.bDeleteCode:</p>
-<p class='stm run hide'> fOut.write(l)</p>
-<p class='stm run hide'> gen.parseLine(l)</p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='stm run hide'> if not l:</p>
-<p class='stm mis'> raise CogError(</p>
-<p class='pln'> "Cog block begun but never ended.",</p>
-<p class='pln'> file=sFileIn, line=firstLineNum)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> if not self.options.bDeleteCode:</p>
-<p class='stm run hide'> fOut.write(l)</p>
-<p class='stm run hide'> gen.parseMarker(l)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='pln'> </p>
-<p class='pln'> # Eat all the lines in the output section. While reading past</p>
-<p class='pln'> # them, compute the md5 hash of the old output.</p>
-<p class='stm run hide'> hasher = hash_factory()</p>
-<p class='stm run hide'> while l and not self.isEndOutputLine(l):</p>
-<p class='stm run hide'> if self.isBeginSpecLine(l):</p>
-<p class='stm mis'> raise CogError("Unexpected '%s'" % self.sBeginSpec,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='stm run hide'> if self.isEndSpecLine(l):</p>
-<p class='stm mis'> raise CogError("Unexpected '%s'" % self.sEndSpec,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='stm run hide'> hasher.update(l)</p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='stm run hide'> curHash = hasher.hexdigest()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> if not l and not self.options.bEofCanBeEnd:</p>
-<p class='pln'> # We reached end of file before we found the end output line.</p>
-<p class='stm mis'> raise CogError("Missing '%s' before end of file." % self.sEndOutput,</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='pln'> </p>
-<p class='pln'> # Write the output of the spec to be the new output if we're</p>
-<p class='pln'> # supposed to generate code.</p>
-<p class='stm run hide'> hasher = hash_factory()</p>
-<p class='stm run hide'> if not self.options.bNoGenerate:</p>
-<p class='stm run hide'> sFile = "%s+%d" % (sFileIn, firstLineNum)</p>
-<p class='stm run hide'> sGen = gen.evaluate(cog=self, globals=globals, fname=sFile)</p>
-<p class='stm run hide'> sGen = self.suffixLines(sGen)</p>
-<p class='stm run hide'> hasher.update(sGen)</p>
-<p class='stm run hide'> fOut.write(sGen)</p>
-<p class='stm run hide'> newHash = hasher.hexdigest()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> bSawCog = True</p>
-<p class='pln'> </p>
-<p class='pln'> # Write the ending output line</p>
-<p class='stm run hide'> hashMatch = self.reEndOutput.search(l)</p>
-<p class='stm run hide'> if self.options.bHashOutput:</p>
-<p class='stm mis'> if hashMatch:</p>
-<p class='stm mis'> oldHash = hashMatch.groupdict()['hash']</p>
-<p class='stm mis'> if oldHash != curHash:</p>
-<p class='stm mis'> raise CogError("Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> file=sFileIn, line=fIn.linenumber())</p>
-<p class='pln'> # Create a new end line with the correct hash.</p>
-<p class='stm mis'> endpieces = l.split(hashMatch.group(0), 1)</p>
-<p class='pln'> else:</p>
-<p class='pln'> # There was no old hash, but we want a new hash.</p>
-<p class='stm mis'> endpieces = l.split(self.sEndOutput, 1)</p>
-<p class='stm mis'> l = (self.sEndFormat % newHash).join(endpieces)</p>
-<p class='pln'> else:</p>
-<p class='pln'> # We don't want hashes output, so if there was one, get rid of</p>
-<p class='pln'> # it.</p>
-<p class='stm run hide'> if hashMatch:</p>
-<p class='stm mis'> l = l.replace(hashMatch.groupdict()['hashsect'], '', 1)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> if not self.options.bDeleteCode:</p>
-<p class='stm run hide'> fOut.write(l)</p>
-<p class='stm run hide'> l = fIn.readline()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> if not bSawCog and self.options.bWarnEmpty:</p>
-<p class='stm mis'> self.showWarning("no cog code found in %s" % sFileIn)</p>
-<p class='pln'> finally:</p>
-<p class='stm run hide'> if fInToClose:</p>
-<p class='stm mis'> fInToClose.close()</p>
-<p class='stm run hide'> if fOutToClose:</p>
-<p class='stm mis'> fOutToClose.close()</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='pln'> # A regex for non-empty lines, used by suffixLines.</p>
-<p class='stm run hide'> reNonEmptyLines = re.compile("^\s*\S+.*$", re.MULTILINE)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def suffixLines(self, text):</p>
-<p class='pln'> """ Add suffixes to the lines in text, if our options desire it.</p>
-<p class='pln'> text is many lines, as a single string.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> if self.options.sSuffix:</p>
-<p class='pln'> # Find all non-blank lines, and add the suffix to the end.</p>
-<p class='stm mis'> repl = r"\g<0>" + self.options.sSuffix.replace('\\', '\\\\')</p>
-<p class='stm mis'> text = self.reNonEmptyLines.sub(repl, text)</p>
-<p class='stm run hide'> return text</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def processString(self, sInput, fname=None):</p>
-<p class='pln'> """ Process sInput as the text to cog.</p>
-<p class='pln'> Return the cogged output as a string.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> fOld = StringIO(sInput)</p>
-<p class='stm run hide'> fNew = StringIO()</p>
-<p class='stm run hide'> self.processFile(fOld, fNew, fname=fname)</p>
-<p class='stm run hide'> return fNew.getvalue()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def replaceFile(self, sOldPath, sNewText):</p>
-<p class='pln'> """ Replace file sOldPath with the contents sNewText</p>
-<p class='pln'> """</p>
-<p class='stm mis'> if not os.access(sOldPath, os.W_OK):</p>
-<p class='pln'> # Need to ensure we can write.</p>
-<p class='stm mis'> if self.options.sMakeWritableCmd:</p>
-<p class='pln'> # Use an external command to make the file writable.</p>
-<p class='stm mis'> cmd = self.options.sMakeWritableCmd.replace('%s', sOldPath)</p>
-<p class='stm mis'> self.stdout.write(os.popen(cmd).read())</p>
-<p class='stm mis'> if not os.access(sOldPath, os.W_OK):</p>
-<p class='stm mis'> raise CogError("Couldn't make %s writable" % sOldPath)</p>
-<p class='pln'> else:</p>
-<p class='pln'> # Can't write!</p>
-<p class='stm mis'> raise CogError("Can't overwrite %s" % sOldPath)</p>
-<p class='stm mis'> f = open(sOldPath, self.sOutputMode)</p>
-<p class='stm mis'> f.write(sNewText)</p>
-<p class='stm mis'> f.close()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def saveIncludePath(self):</p>
-<p class='stm mis'> self.savedInclude = self.options.includePath[:]</p>
-<p class='stm mis'> self.savedSysPath = sys.path[:]</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def restoreIncludePath(self):</p>
-<p class='stm mis'> self.options.includePath = self.savedInclude</p>
-<p class='stm mis'> self.cogmodule.path = self.options.includePath</p>
-<p class='stm mis'> sys.path = self.savedSysPath</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def addToIncludePath(self, includePath):</p>
-<p class='stm mis'> self.cogmodule.path.extend(includePath)</p>
-<p class='stm mis'> sys.path.extend(includePath)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def processOneFile(self, sFile):</p>
-<p class='pln'> """ Process one filename through cog.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm mis'> self.saveIncludePath()</p>
-<p class='pln'> </p>
-<p class='stm mis'> try:</p>
-<p class='stm mis'> self.addToIncludePath(self.options.includePath)</p>
-<p class='pln'> # Since we know where the input file came from,</p>
-<p class='pln'> # push its directory onto the include path.</p>
-<p class='stm mis'> self.addToIncludePath([os.path.dirname(sFile)])</p>
-<p class='pln'> </p>
-<p class='pln'> # Set the file output mode based on whether we want \n or native</p>
-<p class='pln'> # line endings.</p>
-<p class='stm mis'> self.sOutputMode = 'w'</p>
-<p class='stm mis'> if self.options.bNewlines:</p>
-<p class='stm mis'> self.sOutputMode = 'wb'</p>
-<p class='pln'> </p>
-<p class='pln'> # How we process the file depends on where the output is going.</p>
-<p class='stm mis'> if self.options.sOutputName:</p>
-<p class='stm mis'> self.processFile(sFile, self.options.sOutputName, sFile)</p>
-<p class='stm mis'> elif self.options.bReplace:</p>
-<p class='pln'> # We want to replace the cog file with the output,</p>
-<p class='pln'> # but only if they differ.</p>
-<p class='stm mis'> print >>self.stdout, "Cogging %s" % sFile,</p>
-<p class='stm mis'> bNeedNewline = True</p>
-<p class='pln'> </p>
-<p class='stm mis'> try:</p>
-<p class='stm mis'> fOldFile = open(sFile)</p>
-<p class='stm mis'> sOldText = fOldFile.read()</p>
-<p class='stm mis'> fOldFile.close()</p>
-<p class='stm mis'> sNewText = self.processString(sOldText, fname=sFile)</p>
-<p class='stm mis'> if sOldText != sNewText:</p>
-<p class='stm mis'> print >>self.stdout, " (changed)"</p>
-<p class='stm mis'> bNeedNewline = False</p>
-<p class='stm mis'> self.replaceFile(sFile, sNewText)</p>
-<p class='pln'> finally:</p>
-<p class='pln'> # The try-finally block is so we can print a partial line</p>
-<p class='pln'> # with the name of the file, and print (changed) on the</p>
-<p class='pln'> # same line, but also make sure to break the line before</p>
-<p class='pln'> # any traceback.</p>
-<p class='stm mis'> if bNeedNewline:</p>
-<p class='stm mis'> print >>self.stdout</p>
-<p class='pln'> else:</p>
-<p class='stm mis'> self.processFile(sFile, self.stdout, sFile)</p>
-<p class='pln'> finally:</p>
-<p class='stm mis'> self.restoreIncludePath()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def processFileList(self, sFileList):</p>
-<p class='pln'> """ Process the files in a file list.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> flist = open(sFileList)</p>
-<p class='stm mis'> lines = flist.readlines()</p>
-<p class='stm mis'> flist.close()</p>
-<p class='stm mis'> for l in lines:</p>
-<p class='pln'> # Use shlex to parse the line like a shell.</p>
-<p class='stm mis'> lex = shlex.shlex(l, posix=True)</p>
-<p class='stm mis'> lex.whitespace_split = True</p>
-<p class='stm mis'> lex.commenters = '#'</p>
-<p class='pln'> # No escapes, so that backslash can be part of the path</p>
-<p class='stm mis'> lex.escape = ''</p>
-<p class='stm mis'> args = list(lex)</p>
-<p class='stm mis'> if args:</p>
-<p class='stm mis'> self.processArguments(args)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def processArguments(self, args):</p>
-<p class='pln'> """ Process one command-line.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> saved_options = self.options</p>
-<p class='stm mis'> self.options = self.options.clone()</p>
-<p class='pln'> </p>
-<p class='stm mis'> self.options.parseArgs(args[1:])</p>
-<p class='stm mis'> self.options.validate()</p>
-<p class='pln'> </p>
-<p class='stm mis'> if args[0][0] == '@':</p>
-<p class='stm mis'> if self.options.sOutputName:</p>
-<p class='stm mis'> raise CogUsageError("Can't use -o with @file")</p>
-<p class='stm mis'> self.processFileList(args[0][1:])</p>
-<p class='pln'> else:</p>
-<p class='stm mis'> self.processOneFile(args[0])</p>
-<p class='pln'> </p>
-<p class='stm mis'> self.options = saved_options</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def callableMain(self, argv):</p>
-<p class='pln'> """ All of command-line cog, but in a callable form.</p>
-<p class='pln'> This is used by main.</p>
-<p class='pln'> argv is the equivalent of sys.argv.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> argv0 = argv.pop(0)</p>
-<p class='pln'> </p>
-<p class='pln'> # Provide help if asked for anywhere in the command line.</p>
-<p class='stm mis'> if '-?' in argv or '-h' in argv:</p>
-<p class='stm mis'> print >>self.stderr, usage,</p>
-<p class='stm mis'> return</p>
-<p class='pln'> </p>
-<p class='stm mis'> self.options.parseArgs(argv)</p>
-<p class='stm mis'> self.options.validate()</p>
-<p class='pln'> </p>
-<p class='stm mis'> if self.options.bShowVersion:</p>
-<p class='stm mis'> print >>self.stdout, "Cog version %s" % __version__</p>
-<p class='stm mis'> return</p>
-<p class='pln'> </p>
-<p class='stm mis'> if self.options.args:</p>
-<p class='stm mis'> for a in self.options.args:</p>
-<p class='stm mis'> self.processArguments([a])</p>
-<p class='pln'> else:</p>
-<p class='stm mis'> raise CogUsageError("No files to process")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def main(self, argv):</p>
-<p class='pln'> """ Handle the command-line execution for cog.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm mis'> try:</p>
-<p class='stm mis'> self.callableMain(argv)</p>
-<p class='stm mis'> return 0</p>
-<p class='stm mis'> except CogUsageError, err:</p>
-<p class='stm mis'> print >>self.stderr, err</p>
-<p class='stm mis'> print >>self.stderr, "(for help use -?)"</p>
-<p class='stm mis'> return 2</p>
-<p class='stm mis'> except CogGeneratedError, err:</p>
-<p class='stm mis'> print >>self.stderr, "Error: %s" % err</p>
-<p class='stm mis'> return 3</p>
-<p class='stm mis'> except CogError, err:</p>
-<p class='stm mis'> print >>self.stderr, err</p>
-<p class='stm mis'> return 1</p>
-<p class='stm mis'> except:</p>
-<p class='stm mis'> traceback.print_exc(None, self.stderr)</p>
-<p class='stm mis'> return 1</p>
-<p class='pln'> </p>
-<p class='pln'># History:</p>
-<p class='pln'># 20040210: First public version.</p>
-<p class='pln'># 20040220: Text preceding the start and end marker are removed from Python lines.</p>
-<p class='pln'># -v option on the command line shows the version.</p>
-<p class='pln'># 20040311: Make sure the last line of output is properly ended with a newline.</p>
-<p class='pln'># 20040605: Fixed some blank line handling in cog.</p>
-<p class='pln'># Fixed problems with assigning to xml elements in handyxml.</p>
-<p class='pln'># 20040621: Changed all line-ends to LF from CRLF.</p>
-<p class='pln'># 20041002: Refactor some option handling to simplify unittesting the options.</p>
-<p class='pln'># 20041118: cog.out and cog.outl have optional string arguments.</p>
-<p class='pln'># 20041119: File names weren't being properly passed around for warnings, etc.</p>
-<p class='pln'># 20041122: Added cog.firstLineNum: a property with the line number of the [[[cog line.</p>
-<p class='pln'># Added cog.inFile and cog.outFile: the names of the input and output file.</p>
-<p class='pln'># 20041218: Single-line cog generators, with start marker and end marker on</p>
-<p class='pln'># the same line.</p>
-<p class='pln'># 20041230: Keep a single globals dict for all the code fragments in a single</p>
-<p class='pln'># file so they can share state.</p>
-<p class='pln'># 20050206: Added the -x switch to remove all generated output.</p>
-<p class='pln'># 20050218: Now code can be on the marker lines as well.</p>
-<p class='pln'># 20050219: Added -c switch to checksum the output so that edits can be</p>
-<p class='pln'># detected before they are obliterated.</p>
-<p class='pln'># 20050521: Added cog.error, contributed by Alexander Belchenko.</p>
-<p class='pln'># 20050720: Added code deletion and settable globals contributed by Blake Winton.</p>
-<p class='pln'># 20050724: Many tweaks to improve code coverage.</p>
-<p class='pln'># 20050726: Error messages are now printed with no traceback.</p>
-<p class='pln'># Code can no longer appear on the marker lines,</p>
-<p class='pln'># except for single-line style.</p>
-<p class='pln'># -z allows omission of the [[[end]]] marker, and it will be assumed</p>
-<p class='pln'># at the end of the file.</p>
-<p class='pln'># 20050729: Refactor option parsing into a separate class, in preparation for</p>
-<p class='pln'># future features.</p>
-<p class='pln'># 20050805: The cogmodule.path wasn't being properly maintained.</p>
-<p class='pln'># 20050808: Added the -D option to define a global value.</p>
-<p class='pln'># 20050810: The %s in the -w command is dealt with more robustly.</p>
-<p class='pln'># Added the -s option to suffix output lines with a marker.</p>
-<p class='pln'># 20050817: Now @files can have arguments on each line to change the cog's</p>
-<p class='pln'># behavior for that line.</p>
-<p class='pln'># 20051006: Version 2.0</p>
-<p class='pln'># 20080521: -U options lets you create Unix newlines on Windows. Thanks,</p>
-<p class='pln'># Alexander Belchenko.</p>
-<p class='pln'># 20080522: It's now ok to have -d with output to stdout, and now we validate</p>
-<p class='pln'># the args after each line of an @file.</p>
-<p class='pln'># 20090520: Use hashlib where it's available, to avoid a warning.</p>
-<p class='pln'># Use the builtin compile() instead of compiler, for Jython.</p>
-<p class='pln'># Explicitly close files we opened, Jython likes this.</p>
+<p class='pln'><span class='str'>""" Cog code generation tool.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> http://nedbatchelder.com/code/cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Copyright 2004-2009, Ned Batchelder.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>"""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>copy</span><span class='op'>,</span> <span class='nam'>getopt</span><span class='op'>,</span> <span class='nam'>imp</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>,</span> <span class='nam'>re</span><span class='op'>,</span> <span class='nam'>shlex</span><span class='op'>,</span> <span class='nam'>string</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>,</span> <span class='nam'>traceback</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>cStringIO</span> <span class='key'>import</span> <span class='nam'>StringIO</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># The recommended way to compute md5's changed in Python 2.5</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>import</span> <span class='nam'>hashlib</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>hash_factory</span> <span class='op'>=</span> <span class='nam'>hashlib</span><span class='op'>.</span><span class='nam'>md5</span><span class="strut"> </span></p>
+<p class='stm mis'><span class='key'>except</span> <span class='nam'>ImportError</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>import</span> <span class='nam'>md5</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>hash_factory</span> <span class='op'>=</span> <span class='nam'>md5</span><span class='op'>.</span><span class='nam'>new</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>__all__</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'Cog'</span><span class='op'>,</span> <span class='str'>'CogUsageError'</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>__version__</span> <span class='op'>=</span> <span class='str'>'2.2'</span> <span class='com'># History at the end of the file.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>usage</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>cog - generate code with inlined Python code.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>cog [OPTIONS] [INFILE | @FILELIST] ...</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>INFILE is the name of an input file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>FILELIST is the name of a text file containing file names or</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> other @FILELISTs.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'>OPTIONS:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -c Checksum the output to protect it against accidental change.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -d Delete the generator code from the output file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -D name=val Define a global string available to your generator code.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -e Warn if a file has no cog code in it.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -I PATH Add PATH to the list of directories for data files and modules.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -o OUTNAME Write the output to OUTNAME.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -r Replace the input file with the output.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -s STRING Suffix all generated output lines with STRING.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -U Write the output with Unix newlines (only LF line-endings).</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -w CMD Use CMD if the output file needs to be made writable.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> A %s in the CMD will be filled with the filename.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -x Excise all the generated output without running the generators.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -z The [[[end]]] marker can be omitted, and is assumed at eof.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -v Print the version of cog and exit.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -h Print this help.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>"""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Other package modules</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>whiteutils</span> <span class='key'>import</span> <span class='op'>*</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='nam'>Exception</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Any exception raised by Cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>file</span><span class='op'>=</span><span class='str'>''</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='num'>0</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>file</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>Exception</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='str'>"%s(%d): %s"</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>file</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>Exception</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" An error in usage of command-line arguments in cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>pass</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogInternalError</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" An error in the coding of Cog. Should never happen.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>pass</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogGeneratedError</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" An error raised by a user's cog generator.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>pass</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>Redirectable</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" An object with its own stdout and stderr files.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stdout</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>stderr</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>setOutput</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>stdout</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>stderr</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Assign new files for standard out and/or standard error.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>stdout</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span> <span class='op'>=</span> <span class='nam'>stdout</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>stderr</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span> <span class='op'>=</span> <span class='nam'>stderr</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogGenerator</span><span class='op'>(</span><span class='nam'>Redirectable</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" A generator pulled from a source file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>Redirectable</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>markers</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>parseMarker</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>markers</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>parseLine</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>.</span><span class='nam'>strip</span><span class='op'>(</span><span class='str'>'\n'</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>getCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Extract the executable Python code from the generator.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If the markers and lines all have the same prefix</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># (end-of-line comment chars, for example),</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># then remove it from all the lines.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>prefIn</span> <span class='op'>=</span> <span class='nam'>commonPrefix</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>markers</span> <span class='op'>+</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>prefIn</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>markers</span> <span class='op'>=</span> <span class='op'>[</span> <span class='nam'>l</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='nam'>prefIn</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span> <span class='key'>for</span> <span class='nam'>l</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>markers</span> <span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines</span> <span class='op'>=</span> <span class='op'>[</span> <span class='nam'>l</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='nam'>prefIn</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span> <span class='key'>for</span> <span class='nam'>l</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines</span> <span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>evaluate</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>cog</span><span class='op'>,</span> <span class='nam'>globals</span><span class='op'>,</span> <span class='nam'>fname</span><span class='op'>=</span><span class='str'>'cog generator'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># figure out the right whitespace prefix for the output</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>prefOut</span> <span class='op'>=</span> <span class='nam'>whitePrefix</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>markers</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>intext</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>intext</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># In Python 2.2, the last line has to end in a newline.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>intext</span> <span class='op'>=</span> <span class='str'>"import cog\n"</span> <span class='op'>+</span> <span class='nam'>intext</span> <span class='op'>+</span> <span class='str'>"\n"</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>code</span> <span class='op'>=</span> <span class='nam'>compile</span><span class='op'>(</span><span class='nam'>intext</span><span class='op'>,</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>fname</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'exec'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Make sure the "cog" module has our state.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>cog</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>msg</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>msg</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>cog</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>out</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>out</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>cog</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>outl</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>outl</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>cog</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>error</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>error</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>outstring</span> <span class='op'>=</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>eval</span><span class='op'>(</span><span class='nam'>code</span><span class='op'>,</span> <span class='nam'>globals</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># We need to make sure that the last line in the output</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># ends with a newline, or it will be joined to the</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># end-output line, ruining cog's idempotency.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>outstring</span> <span class='key'>and</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>outstring</span><span class='op'>[</span><span class='op'>-</span><span class='num'>1</span><span class='op'>]</span> <span class='op'>!=</span> <span class='str'>'\n'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>outstring</span> <span class='op'>+=</span> <span class='str'>'\n'</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>outstring</span><span class='op'>,</span> <span class='nam'>prefOut</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>msg</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>,</span> <span class='str'>"Message: "</span><span class='op'>+</span><span class='nam'>s</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>out</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sOut</span><span class='op'>=</span><span class='str'>''</span><span class='op'>,</span> <span class='nam'>dedent</span><span class='op'>=</span><span class='nam'>False</span><span class='op'>,</span> <span class='nam'>trimblanklines</span><span class='op'>=</span><span class='nam'>False</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The cog.out function.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>trimblanklines</span> <span class='key'>and</span> <span class='op'>(</span><span class='str'>'\n'</span> <span class='key'>in</span> <span class='nam'>sOut</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>lines</span> <span class='op'>=</span> <span class='nam'>sOut</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='str'>'\n'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>lines</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>.</span><span class='nam'>strip</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='str'>''</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>del</span> <span class='nam'>lines</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>lines</span> <span class='key'>and</span> <span class='nam'>lines</span><span class='op'>[</span><span class='op'>-</span><span class='num'>1</span><span class='op'>]</span><span class='op'>.</span><span class='nam'>strip</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>==</span> <span class='str'>''</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>del</span> <span class='nam'>lines</span><span class='op'>[</span><span class='op'>-</span><span class='num'>1</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sOut</span> <span class='op'>=</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>lines</span><span class='op'>)</span><span class='op'>+</span><span class='str'>'\n'</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>dedent</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sOut</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>sOut</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>outstring</span> <span class='op'>+=</span> <span class='nam'>sOut</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>outl</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sOut</span><span class='op'>=</span><span class='str'>''</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kw</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The cog.outl function.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>out</span><span class='op'>(</span><span class='nam'>sOut</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kw</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>out</span><span class='op'>(</span><span class='str'>'\n'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>error</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>=</span><span class='str'>'Error raised by cog generator.'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The cog.error function.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Instead of raising standard python errors, cog generators can use</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> this function. It will display the error without a scary Python</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> traceback.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogGeneratedError</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>NumberedFileReader</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" A decorator for files that counts the readline()'s called.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>f</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>f</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>n</span> <span class='op'>=</span> <span class='num'>0</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>readline</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>f</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>l</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>n</span> <span class='op'>+=</span> <span class='num'>1</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>l</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>linenumber</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>n</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogOptions</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Options for a run of cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Defaults for argument values.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>args</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>includePath</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>defines</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bShowVersion</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sMakeWritableCmd</span> <span class='op'>=</span> <span class='nam'>None</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bReplace</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bNoGenerate</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputName</span> <span class='op'>=</span> <span class='nam'>None</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bWarnEmpty</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bHashOutput</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bDeleteCode</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bEofCanBeEnd</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sSuffix</span> <span class='op'>=</span> <span class='nam'>None</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bNewlines</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__cmp__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>other</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Comparison operator for tests to use.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='op'>.</span><span class='nam'>__cmp__</span><span class='op'>(</span><span class='nam'>other</span><span class='op'>.</span><span class='nam'>__dict__</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>clone</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Make a clone of these options, for further refinement.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='nam'>copy</span><span class='op'>.</span><span class='nam'>deepcopy</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>addToIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>dirs</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Add directories to the include path.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>dirs</span> <span class='op'>=</span> <span class='nam'>dirs</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>pathsep</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>includePath</span><span class='op'>.</span><span class='nam'>extend</span><span class='op'>(</span><span class='nam'>dirs</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>parseArgs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>argv</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Parse the command line arguments.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>opts</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>args</span> <span class='op'>=</span> <span class='nam'>getopt</span><span class='op'>.</span><span class='nam'>getopt</span><span class='op'>(</span><span class='nam'>argv</span><span class='op'>,</span> <span class='str'>'cdD:eI:o:rs:Uvw:xz'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>except</span> <span class='nam'>getopt</span><span class='op'>.</span><span class='nam'>error</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='nam'>msg</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Handle the command line arguments.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>o</span><span class='op'>,</span> <span class='nam'>a</span> <span class='key'>in</span> <span class='nam'>opts</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-c'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bHashOutput</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-d'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bDeleteCode</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-D'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>a</span><span class='op'>.</span><span class='nam'>count</span><span class='op'>(</span><span class='str'>'='</span><span class='op'>)</span> <span class='op'><</span> <span class='num'>1</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='str'>"-D takes a name=value argument"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>value</span> <span class='op'>=</span> <span class='nam'>a</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='str'>'='</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>defines</span><span class='op'>[</span><span class='nam'>name</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>value</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-e'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bWarnEmpty</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-I'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>addToIncludePath</span><span class='op'>(</span><span class='nam'>a</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-o'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputName</span> <span class='op'>=</span> <span class='nam'>a</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-r'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bReplace</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-s'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sSuffix</span> <span class='op'>=</span> <span class='nam'>a</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-U'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bNewlines</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-v'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bShowVersion</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-w'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sMakeWritableCmd</span> <span class='op'>=</span> <span class='nam'>a</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-x'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bNoGenerate</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>o</span> <span class='op'>==</span> <span class='str'>'-z'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bEofCanBeEnd</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Since getopt.getopt is given a list of possible flags,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># this is an internal error.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogInternalError</span><span class='op'>(</span><span class='str'>"Don't understand argument %s"</span> <span class='op'>%</span> <span class='nam'>o</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>validate</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Does nothing if everything is OK, raises CogError's if it's not.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bReplace</span> <span class='key'>and</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bDeleteCode</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='str'>"Can't use -d with -r (or you would delete all your source!)"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>bReplace</span> <span class='key'>and</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputName</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='str'>"Can't use -o with -r (they are opposites)"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>Cog</span><span class='op'>(</span><span class='nam'>Redirectable</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" The Cog engine.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>Redirectable</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sBeginSpec</span> <span class='op'>=</span> <span class='str'>'[[[cog'</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndSpec</span> <span class='op'>=</span> <span class='str'>']]]'</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndOutput</span> <span class='op'>=</span> <span class='str'>'[[[end]]]'</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>reEndOutput</span> <span class='op'>=</span> <span class='nam'>re</span><span class='op'>.</span><span class='nam'>compile</span><span class='op'>(</span><span class='str'>r'\[\[\[end]]](?P<hashsect> *\(checksum: (?P<hash>[a-f0-9]+)\))'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndFormat</span> <span class='op'>=</span> <span class='str'>'[[[end]]] (checksum: %s)'</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputMode</span> <span class='op'>=</span> <span class='str'>'w'</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>installCogModule</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>showWarning</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>,</span> <span class='str'>"Warning:"</span><span class='op'>,</span> <span class='nam'>msg</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>isBeginSpecLine</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sBeginSpec</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>isEndSpecLine</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndSpec</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span> <span class='key'>and</span> <span class='xx'>\</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndOutputLine</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>isEndOutputLine</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndOutput</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>installCogModule</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Magic mumbo-jumbo so that imported Python modules</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> can say "import cog" and get our state.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span> <span class='op'>=</span> <span class='nam'>imp</span><span class='op'>.</span><span class='nam'>new_module</span><span class='op'>(</span><span class='str'>'cog'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>path</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>modules</span><span class='op'>[</span><span class='str'>'cog'</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>processFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>fIn</span><span class='op'>,</span> <span class='nam'>fOut</span><span class='op'>,</span> <span class='nam'>fname</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>globals</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Process an input file object to an output file object.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fIn and fOut can be file objects, or file names.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sFileIn</span> <span class='op'>=</span> <span class='nam'>fname</span> <span class='key'>or</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sFileOut</span> <span class='op'>=</span> <span class='nam'>fname</span> <span class='key'>or</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fInToClose</span> <span class='op'>=</span> <span class='nam'>fOutToClose</span> <span class='op'>=</span> <span class='nam'>None</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Convert filenames to files.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>fIn</span><span class='op'>,</span> <span class='nam'>basestring</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Open the input file.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sFileIn</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fIn</span> <span class='op'>=</span> <span class='nam'>fInToClose</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>fIn</span><span class='op'>,</span> <span class='str'>'r'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>fOut</span><span class='op'>,</span> <span class='nam'>basestring</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Open the output file.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sFileOut</span> <span class='op'>=</span> <span class='nam'>fOut</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fOut</span> <span class='op'>=</span> <span class='nam'>fOutToClose</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>fOut</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputMode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fIn</span> <span class='op'>=</span> <span class='nam'>NumberedFileReader</span><span class='op'>(</span><span class='nam'>fIn</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>bSawCog</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>inFile</span> <span class='op'>=</span> <span class='nam'>sFileIn</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>outFile</span> <span class='op'>=</span> <span class='nam'>sFileOut</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># The globals dict we'll use for this file.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>globals</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>globals</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If there are any global defines, put them in the globals.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>globals</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>defines</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># loop over generator chunks</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>while</span> <span class='nam'>l</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Find the next spec begin</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>while</span> <span class='nam'>l</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBeginSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Unexpected '%s'"</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndSpec</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndOutputLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Unexpected '%s'"</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndOutput</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOut</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>l</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>break</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bDeleteCode</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOut</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># l is the begin spec</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>gen</span> <span class='op'>=</span> <span class='nam'>CogGenerator</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>gen</span><span class='op'>.</span><span class='nam'>setOutput</span><span class='op'>(</span><span class='nam'>stdout</span><span class='op'>=</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>gen</span><span class='op'>.</span><span class='nam'>parseMarker</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>firstLineNum</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>firstLineNum</span> <span class='op'>=</span> <span class='nam'>firstLineNum</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If the spec begin is also a spec end, then process the single</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># line of code inside.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>beg</span> <span class='op'>=</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sBeginSpec</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>end</span> <span class='op'>=</span> <span class='nam'>string</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndSpec</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>beg</span> <span class='op'>></span> <span class='nam'>end</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Cog code markers inverted"</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>firstLineNum</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sCode</span> <span class='op'>=</span> <span class='nam'>l</span><span class='op'>[</span><span class='nam'>beg</span><span class='op'>+</span><span class='nam'>len</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>sBeginSpec</span><span class='op'>)</span><span class='op'>:</span><span class='nam'>end</span><span class='op'>]</span><span class='op'>.</span><span class='nam'>strip</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>gen</span><span class='op'>.</span><span class='nam'>parseLine</span><span class='op'>(</span><span class='nam'>sCode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Deal with an ordinary code block.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Get all the lines in the spec</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>while</span> <span class='nam'>l</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBeginSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Unexpected '%s'"</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sBeginSpec</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndOutputLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Unexpected '%s'"</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndOutput</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bDeleteCode</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOut</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>gen</span><span class='op'>.</span><span class='nam'>parseLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>l</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"Cog block begun but never ended."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>firstLineNum</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bDeleteCode</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOut</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>gen</span><span class='op'>.</span><span class='nam'>parseMarker</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Eat all the lines in the output section. While reading past</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># them, compute the md5 hash of the old output.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>hasher</span> <span class='op'>=</span> <span class='nam'>hash_factory</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>while</span> <span class='nam'>l</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndOutputLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBeginSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Unexpected '%s'"</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sBeginSpec</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isEndSpecLine</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Unexpected '%s'"</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndSpec</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>hasher</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>curHash</span> <span class='op'>=</span> <span class='nam'>hasher</span><span class='op'>.</span><span class='nam'>hexdigest</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>l</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bEofCanBeEnd</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># We reached end of file before we found the end output line.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Missing '%s' before end of file."</span> <span class='op'>%</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndOutput</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Write the output of the spec to be the new output if we're </span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># supposed to generate code.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>hasher</span> <span class='op'>=</span> <span class='nam'>hash_factory</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bNoGenerate</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sFile</span> <span class='op'>=</span> <span class='str'>"%s+%d"</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>firstLineNum</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sGen</span> <span class='op'>=</span> <span class='nam'>gen</span><span class='op'>.</span><span class='nam'>evaluate</span><span class='op'>(</span><span class='nam'>cog</span><span class='op'>=</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>globals</span><span class='op'>=</span><span class='nam'>globals</span><span class='op'>,</span> <span class='nam'>fname</span><span class='op'>=</span><span class='nam'>sFile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>sGen</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>suffixLines</span><span class='op'>(</span><span class='nam'>sGen</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>hasher</span><span class='op'>.</span><span class='nam'>update</span><span class='op'>(</span><span class='nam'>sGen</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOut</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>sGen</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>newHash</span> <span class='op'>=</span> <span class='nam'>hasher</span><span class='op'>.</span><span class='nam'>hexdigest</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>bSawCog</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Write the ending output line</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>hashMatch</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>reEndOutput</span><span class='op'>.</span><span class='nam'>search</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bHashOutput</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>hashMatch</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>oldHash</span> <span class='op'>=</span> <span class='nam'>hashMatch</span><span class='op'>.</span><span class='nam'>groupdict</span><span class='op'>(</span><span class='op'>)</span><span class='op'>[</span><span class='str'>'hash'</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>oldHash</span> <span class='op'>!=</span> <span class='nam'>curHash</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>file</span><span class='op'>=</span><span class='nam'>sFileIn</span><span class='op'>,</span> <span class='nam'>line</span><span class='op'>=</span><span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>linenumber</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Create a new end line with the correct hash.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>endpieces</span> <span class='op'>=</span> <span class='nam'>l</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='nam'>hashMatch</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='num'>0</span><span class='op'>)</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># There was no old hash, but we want a new hash.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>endpieces</span> <span class='op'>=</span> <span class='nam'>l</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndOutput</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>l</span> <span class='op'>=</span> <span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>sEndFormat</span> <span class='op'>%</span> <span class='nam'>newHash</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>endpieces</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># We don't want hashes output, so if there was one, get rid of</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># it.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>hashMatch</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>l</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='nam'>hashMatch</span><span class='op'>.</span><span class='nam'>groupdict</span><span class='op'>(</span><span class='op'>)</span><span class='op'>[</span><span class='str'>'hashsect'</span><span class='op'>]</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bDeleteCode</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOut</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>fIn</span><span class='op'>.</span><span class='nam'>readline</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>bSawCog</span> <span class='key'>and</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bWarnEmpty</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>showWarning</span><span class='op'>(</span><span class='str'>"no cog code found in %s"</span> <span class='op'>%</span> <span class='nam'>sFileIn</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>fInToClose</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fInToClose</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>fOutToClose</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fOutToClose</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># A regex for non-empty lines, used by suffixLines.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>reNonEmptyLines</span> <span class='op'>=</span> <span class='nam'>re</span><span class='op'>.</span><span class='nam'>compile</span><span class='op'>(</span><span class='str'>"^\s*\S+.*$"</span><span class='op'>,</span> <span class='nam'>re</span><span class='op'>.</span><span class='nam'>MULTILINE</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>suffixLines</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>text</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Add suffixes to the lines in text, if our options desire it.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> text is many lines, as a single string.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sSuffix</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Find all non-blank lines, and add the suffix to the end.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>repl</span> <span class='op'>=</span> <span class='str'>r"\g<0>"</span> <span class='op'>+</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sSuffix</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='str'>'\\'</span><span class='op'>,</span> <span class='str'>'\\\\'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>text</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>reNonEmptyLines</span><span class='op'>.</span><span class='nam'>sub</span><span class='op'>(</span><span class='nam'>repl</span><span class='op'>,</span> <span class='nam'>text</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>text</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>processString</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sInput</span><span class='op'>,</span> <span class='nam'>fname</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Process sInput as the text to cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Return the cogged output as a string.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fOld</span> <span class='op'>=</span> <span class='nam'>StringIO</span><span class='op'>(</span><span class='nam'>sInput</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>fNew</span> <span class='op'>=</span> <span class='nam'>StringIO</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processFile</span><span class='op'>(</span><span class='nam'>fOld</span><span class='op'>,</span> <span class='nam'>fNew</span><span class='op'>,</span> <span class='nam'>fname</span><span class='op'>=</span><span class='nam'>fname</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>fNew</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>replaceFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sOldPath</span><span class='op'>,</span> <span class='nam'>sNewText</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Replace file sOldPath with the contents sNewText</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>sOldPath</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Need to ensure we can write.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sMakeWritableCmd</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Use an external command to make the file writable.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>cmd</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sMakeWritableCmd</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='str'>'%s'</span><span class='op'>,</span> <span class='nam'>sOldPath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>popen</span><span class='op'>(</span><span class='nam'>cmd</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>read</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>sOldPath</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Couldn't make %s writable"</span> <span class='op'>%</span> <span class='nam'>sOldPath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Can't write!</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogError</span><span class='op'>(</span><span class='str'>"Can't overwrite %s"</span> <span class='op'>%</span> <span class='nam'>sOldPath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>sOldPath</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputMode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>sNewText</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>saveIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>savedInclude</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>includePath</span><span class='op'>[</span><span class='op'>:</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>savedSysPath</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>[</span><span class='op'>:</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>restoreIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>includePath</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>savedInclude</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>path</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>includePath</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>savedSysPath</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>addToIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>includePath</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cogmodule</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>extend</span><span class='op'>(</span><span class='nam'>includePath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>extend</span><span class='op'>(</span><span class='nam'>includePath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>processOneFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sFile</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Process one filename through cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>saveIncludePath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>addToIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>includePath</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Since we know where the input file came from,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># push its directory onto the include path.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>addToIncludePath</span><span class='op'>(</span><span class='op'>[</span><span class='nam'>os</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>.</span><span class='nam'>dirname</span><span class='op'>(</span><span class='nam'>sFile</span><span class='op'>)</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Set the file output mode based on whether we want \n or native</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># line endings.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputMode</span> <span class='op'>=</span> <span class='str'>'w'</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bNewlines</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sOutputMode</span> <span class='op'>=</span> <span class='str'>'wb'</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># How we process the file depends on where the output is going.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sOutputName</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processFile</span><span class='op'>(</span><span class='nam'>sFile</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sOutputName</span><span class='op'>,</span> <span class='nam'>sFile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>elif</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bReplace</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># We want to replace the cog file with the output,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># but only if they differ.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>,</span> <span class='str'>"Cogging %s"</span> <span class='op'>%</span> <span class='nam'>sFile</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>bNeedNewline</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fOldFile</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>sFile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sOldText</span> <span class='op'>=</span> <span class='nam'>fOldFile</span><span class='op'>.</span><span class='nam'>read</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>fOldFile</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sNewText</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>sOldText</span><span class='op'>,</span> <span class='nam'>fname</span><span class='op'>=</span><span class='nam'>sFile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>sOldText</span> <span class='op'>!=</span> <span class='nam'>sNewText</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>,</span> <span class='str'>" (changed)"</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>bNeedNewline</span> <span class='op'>=</span> <span class='nam'>False</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>replaceFile</span><span class='op'>(</span><span class='nam'>sFile</span><span class='op'>,</span> <span class='nam'>sNewText</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># The try-finally block is so we can print a partial line</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># with the name of the file, and print (changed) on the</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># same line, but also make sure to break the line before</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># any traceback.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>bNeedNewline</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processFile</span><span class='op'>(</span><span class='nam'>sFile</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>,</span> <span class='nam'>sFile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>restoreIncludePath</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>processFileList</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sFileList</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Process the files in a file list.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>flist</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>sFileList</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>lines</span> <span class='op'>=</span> <span class='nam'>flist</span><span class='op'>.</span><span class='nam'>readlines</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>flist</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>l</span> <span class='key'>in</span> <span class='nam'>lines</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Use shlex to parse the line like a shell.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>lex</span> <span class='op'>=</span> <span class='nam'>shlex</span><span class='op'>.</span><span class='nam'>shlex</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>,</span> <span class='nam'>posix</span><span class='op'>=</span><span class='nam'>True</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>lex</span><span class='op'>.</span><span class='nam'>whitespace_split</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>lex</span><span class='op'>.</span><span class='nam'>commenters</span> <span class='op'>=</span> <span class='str'>'#'</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># No escapes, so that backslash can be part of the path</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>lex</span><span class='op'>.</span><span class='nam'>escape</span> <span class='op'>=</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>args</span> <span class='op'>=</span> <span class='nam'>list</span><span class='op'>(</span><span class='nam'>lex</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>args</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processArguments</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>processArguments</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Process one command-line.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>saved_options</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>clone</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>1</span><span class='op'>:</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>validate</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span> <span class='op'>==</span> <span class='str'>'@'</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>sOutputName</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='str'>"Can't use -o with @file"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processFileList</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>[</span><span class='num'>1</span><span class='op'>:</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processOneFile</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span> <span class='op'>=</span> <span class='nam'>saved_options</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>callableMain</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>argv</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" All of command-line cog, but in a callable form.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is used by main.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> argv is the equivalent of sys.argv.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>argv0</span> <span class='op'>=</span> <span class='nam'>argv</span><span class='op'>.</span><span class='nam'>pop</span><span class='op'>(</span><span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Provide help if asked for anywhere in the command line.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='str'>'-?'</span> <span class='key'>in</span> <span class='nam'>argv</span> <span class='key'>or</span> <span class='str'>'-h'</span> <span class='key'>in</span> <span class='nam'>argv</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>,</span> <span class='nam'>usage</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='nam'>argv</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>validate</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bShowVersion</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stdout</span><span class='op'>,</span> <span class='str'>"Cog version %s"</span> <span class='op'>%</span> <span class='nam'>__version__</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>a</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>args</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>processArguments</span><span class='op'>(</span><span class='op'>[</span><span class='nam'>a</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>raise</span> <span class='nam'>CogUsageError</span><span class='op'>(</span><span class='str'>"No files to process"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>main</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>argv</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Handle the command-line execution for cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='nam'>argv</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='num'>0</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>except</span> <span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>err</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>,</span> <span class='nam'>err</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>,</span> <span class='str'>"(for help use -?)"</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='num'>2</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>except</span> <span class='nam'>CogGeneratedError</span><span class='op'>,</span> <span class='nam'>err</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>,</span> <span class='str'>"Error: %s"</span> <span class='op'>%</span> <span class='nam'>err</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='num'>3</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>except</span> <span class='nam'>CogError</span><span class='op'>,</span> <span class='nam'>err</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>print</span> <span class='op'>>></span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>,</span> <span class='nam'>err</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='num'>1</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>except</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>traceback</span><span class='op'>.</span><span class='nam'>print_exc</span><span class='op'>(</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>stderr</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='num'>1</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># History:</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20040210: First public version.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20040220: Text preceding the start and end marker are removed from Python lines.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># -v option on the command line shows the version.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20040311: Make sure the last line of output is properly ended with a newline.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20040605: Fixed some blank line handling in cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Fixed problems with assigning to xml elements in handyxml.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20040621: Changed all line-ends to LF from CRLF.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20041002: Refactor some option handling to simplify unittesting the options.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20041118: cog.out and cog.outl have optional string arguments.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20041119: File names weren't being properly passed around for warnings, etc.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20041122: Added cog.firstLineNum: a property with the line number of the [[[cog line.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Added cog.inFile and cog.outFile: the names of the input and output file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20041218: Single-line cog generators, with start marker and end marker on</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># the same line.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20041230: Keep a single globals dict for all the code fragments in a single</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># file so they can share state.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050206: Added the -x switch to remove all generated output.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050218: Now code can be on the marker lines as well.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050219: Added -c switch to checksum the output so that edits can be</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># detected before they are obliterated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050521: Added cog.error, contributed by Alexander Belchenko.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050720: Added code deletion and settable globals contributed by Blake Winton.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050724: Many tweaks to improve code coverage.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050726: Error messages are now printed with no traceback.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Code can no longer appear on the marker lines,</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># except for single-line style.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># -z allows omission of the [[[end]]] marker, and it will be assumed</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># at the end of the file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050729: Refactor option parsing into a separate class, in preparation for</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># future features.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050805: The cogmodule.path wasn't being properly maintained.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050808: Added the -D option to define a global value.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050810: The %s in the -w command is dealt with more robustly.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Added the -s option to suffix output lines with a marker.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20050817: Now @files can have arguments on each line to change the cog's</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># behavior for that line.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20051006: Version 2.0</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20080521: -U options lets you create Unix newlines on Windows. Thanks,</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Alexander Belchenko.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20080522: It's now ok to have -d with output to stdout, and now we validate</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># the args after each line of an @file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># 20090520: Use hashlib where it's available, to avoid a warning.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Use the builtin compile() instead of compiler, for Jython.</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Explicitly close files we opened, Jython likes this.</span><span class="strut"> </span></p>
</td>
</tr>
diff --git a/doc/sample_html/cogapp_makefiles.html b/doc/sample_html/cogapp_makefiles.html index d1c7e56..4d50521 100644 --- a/doc/sample_html/cogapp_makefiles.html +++ b/doc/sample_html/cogapp_makefiles.html @@ -104,70 +104,70 @@ function toggle_lines(btn, cls) { </td>
<td class='text' valign='top'>
-<p class='pln'>""" Dictionary-to-filetree functions, to create test files for testing.</p>
-<p class='pln'> http://nedbatchelder.com/code/cog</p>
-<p class='pln'> </p>
-<p class='pln'> Copyright 2004-2009, Ned Batchelder.</p>
-<p class='pln'>"""</p>
-<p class='pln'> </p>
-<p class='stm run hide'>import path # Non-standard, from http://www.jorendorff.com/articles/python/path</p>
-<p class='stm run hide'>from whiteutils import reindentBlock</p>
-<p class='pln'> </p>
-<p class='stm run hide'>__version__ = '1.0.20040126'</p>
-<p class='stm run hide'>__all__ = ['makeFiles', 'removeFiles']</p>
-<p class='pln'> </p>
-<p class='stm run hide'>def makeFiles(d, basedir='.', raw=False):</p>
-<p class='pln'> """ Create files from the dictionary d, in the directory named by dirpath.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> dirpath = path.path(basedir)</p>
-<p class='stm mis'> for name, contents in d.items():</p>
-<p class='stm mis'> child = dirpath / name</p>
-<p class='stm mis'> if isinstance(contents, basestring):</p>
-<p class='stm mis'> mode = 'w'</p>
-<p class='stm mis'> if raw:</p>
-<p class='stm mis'> mode = 'wb'</p>
-<p class='stm mis'> f = open(child, mode)</p>
-<p class='stm mis'> if not raw:</p>
-<p class='stm mis'> contents = reindentBlock(contents)</p>
-<p class='stm mis'> f.write(contents)</p>
-<p class='stm mis'> f.close()</p>
-<p class='pln'> else:</p>
-<p class='stm mis'> if not child.exists():</p>
-<p class='stm mis'> child.mkdir()</p>
-<p class='stm mis'> makeFiles(contents, child, raw=raw)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>def removeFiles(d, basedir='.'):</p>
-<p class='pln'> """ Remove the files created by makeFiles.</p>
-<p class='pln'> Directories are removed if they are empty.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> dirpath = path.path(basedir)</p>
-<p class='stm mis'> for name, contents in d.items():</p>
-<p class='stm mis'> child = dirpath / name</p>
-<p class='stm mis'> if isinstance(contents, basestring):</p>
-<p class='stm mis'> child.remove()</p>
-<p class='pln'> else:</p>
-<p class='stm mis'> removeFiles(contents, child)</p>
-<p class='stm mis'> if not child.files() and not child.dirs():</p>
-<p class='stm mis'> child.rmdir()</p>
-<p class='pln'> </p>
-<p class='exc'>if __name__ == '__main__': #pragma: no cover</p>
-<p class='pln'> # Try it a little.</p>
-<p class='exc'> d = {</p>
-<p class='pln'> 'test_makefiles': {</p>
-<p class='pln'> 'hey.txt': """\</p>
-<p class='pln'> This is hey.txt.</p>
-<p class='pln'> It's very simple.</p>
-<p class='pln'> """,</p>
-<p class='pln'> 'subdir': {</p>
-<p class='pln'> 'fooey': """\</p>
-<p class='pln'> # Fooey</p>
-<p class='pln'> Kablooey</p>
-<p class='pln'> Ew.</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> }</p>
-<p class='pln'> }</p>
-<p class='exc'> makeFiles(d)</p>
+<p class='pln'><span class='str'>""" Dictionary-to-filetree functions, to create test files for testing.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> http://nedbatchelder.com/code/cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Copyright 2004-2009, Ned Batchelder.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>"""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>path</span> <span class='com'># Non-standard, from http://www.jorendorff.com/articles/python/path</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>whiteutils</span> <span class='key'>import</span> <span class='nam'>reindentBlock</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>__version__</span> <span class='op'>=</span> <span class='str'>'1.0.20040126'</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='nam'>__all__</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'makeFiles'</span><span class='op'>,</span> <span class='str'>'removeFiles'</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>def</span> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>,</span> <span class='nam'>basedir</span><span class='op'>=</span><span class='str'>'.'</span><span class='op'>,</span> <span class='nam'>raw</span><span class='op'>=</span><span class='nam'>False</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Create files from the dictionary d, in the directory named by dirpath.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>dirpath</span> <span class='op'>=</span> <span class='nam'>path</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>(</span><span class='nam'>basedir</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>contents</span> <span class='key'>in</span> <span class='nam'>d</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>child</span> <span class='op'>=</span> <span class='nam'>dirpath</span> <span class='op'>/</span> <span class='nam'>name</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>contents</span><span class='op'>,</span> <span class='nam'>basestring</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>mode</span> <span class='op'>=</span> <span class='str'>'w'</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>raw</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>mode</span> <span class='op'>=</span> <span class='str'>'wb'</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>child</span><span class='op'>,</span> <span class='nam'>mode</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>raw</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>contents</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>contents</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>write</span><span class='op'>(</span><span class='nam'>contents</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>exists</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>mkdir</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>contents</span><span class='op'>,</span> <span class='nam'>child</span><span class='op'>,</span> <span class='nam'>raw</span><span class='op'>=</span><span class='nam'>raw</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>def</span> <span class='nam'>removeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>,</span> <span class='nam'>basedir</span><span class='op'>=</span><span class='str'>'.'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Remove the files created by makeFiles.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Directories are removed if they are empty.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>dirpath</span> <span class='op'>=</span> <span class='nam'>path</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>(</span><span class='nam'>basedir</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>contents</span> <span class='key'>in</span> <span class='nam'>d</span><span class='op'>.</span><span class='nam'>items</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>child</span> <span class='op'>=</span> <span class='nam'>dirpath</span> <span class='op'>/</span> <span class='nam'>name</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>contents</span><span class='op'>,</span> <span class='nam'>basestring</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>remove</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>removeFiles</span><span class='op'>(</span><span class='nam'>contents</span><span class='op'>,</span> <span class='nam'>child</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>files</span><span class='op'>(</span><span class='op'>)</span> <span class='key'>and</span> <span class='key'>not</span> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>dirs</span><span class='op'>(</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>child</span><span class='op'>.</span><span class='nam'>rmdir</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='exc'><span class='key'>if</span> <span class='nam'>__name__</span> <span class='op'>==</span> <span class='str'>'__main__'</span><span class='op'>:</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Try it a little.</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test_makefiles'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'hey.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is hey.txt.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> It's very simple.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'subdir'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'fooey'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Kablooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Ew.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
</td>
</tr>
diff --git a/doc/sample_html/cogapp_test_cogapp.html b/doc/sample_html/cogapp_test_cogapp.html index 2f19e05..23355ae 100644 --- a/doc/sample_html/cogapp_test_cogapp.html +++ b/doc/sample_html/cogapp_test_cogapp.html @@ -2000,1966 +2000,1966 @@ function toggle_lines(btn, cls) { </td>
<td class='text' valign='top'>
-<p class='pln'>""" Test cogapp.</p>
-<p class='pln'> http://nedbatchelder.com/code/cog</p>
-<p class='pln'> </p>
-<p class='pln'> Copyright 2004-2009, Ned Batchelder.</p>
-<p class='pln'>"""</p>
-<p class='pln'> </p>
-<p class='stm run hide'>import unittest</p>
-<p class='stm run hide'>import os, random, re, StringIO, stat, sys, tempfile</p>
-<p class='stm run hide'>import path # Non-standard, from http://www.jorendorff.com/articles/python/path</p>
-<p class='stm run hide'>from cogapp import Cog, CogOptions, CogGenerator</p>
-<p class='stm run hide'>from cogapp import CogError, CogUsageError, CogGeneratedError</p>
-<p class='stm run hide'>from cogapp import usage, __version__</p>
-<p class='stm run hide'>from whiteutils import reindentBlock</p>
-<p class='stm run hide'>from makefiles import *</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class TestCase(unittest.TestCase):</p>
-<p class='pln'> """ Base class for all Cog test cases. Adds utility methods I like.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> def assertRaisesMsg(self, excClass, msg, callableObj, *args, **kwargs):</p>
-<p class='pln'> """ Just like unittest.TestCase.assertRaises,</p>
-<p class='pln'> but checks that the message is right too.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> try:</p>
-<p class='stm run hide'> callableObj(*args, **kwargs)</p>
-<p class='stm run hide'> except excClass, exc:</p>
-<p class='stm run hide'> excMsg = str(exc)</p>
-<p class='stm run hide'> if not msg:</p>
-<p class='pln'> # No message provided: it passes.</p>
-<p class='exc'> return #pragma: no cover</p>
-<p class='stm run hide'> elif excMsg == msg:</p>
-<p class='pln'> # Message provided, and we got the right message: it passes.</p>
-<p class='stm run hide'> return</p>
-<p class='exc'> else: #pragma: no cover</p>
-<p class='pln'> # Message provided, and it didn't match: fail!</p>
-<p class='exc'> raise self.failureException("Right exception, wrong message: got '%s' expected '%s'" % (excMsg, msg))</p>
-<p class='exc'> else: #pragma: no cover</p>
-<p class='exc'> if hasattr(excClass,'__name__'):</p>
-<p class='exc'> excName = excClass.__name__</p>
-<p class='exc'> else:</p>
-<p class='exc'> excName = str(excClass)</p>
-<p class='exc'> raise self.failureException("Expected to raise %s, didn't get an exception at all" % excName)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogTestsInMemory(TestCase):</p>
-<p class='pln'> """ Test cases for cogapp.Cog()</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoCog(self):</p>
-<p class='stm run hide'> strings = [</p>
-<p class='pln'> '',</p>
-<p class='pln'> ' ',</p>
-<p class='pln'> ' \t \t \tx',</p>
-<p class='pln'> 'hello',</p>
-<p class='pln'> 'the cat\nin the\nhat.',</p>
-<p class='pln'> 'Horton\n\tHears A\n\t\tWho'</p>
-<p class='pln'> ]</p>
-<p class='stm run hide'> for s in strings:</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(s), s)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSimple(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> Some text.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import cog</p>
-<p class='pln'> cog.outl("This is line one\\n")</p>
-<p class='pln'> cog.outl("This is line two")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> gobbledegook.</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> epilogue.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> outfile = """\</p>
-<p class='pln'> Some text.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import cog</p>
-<p class='pln'> cog.outl("This is line one\\n")</p>
-<p class='pln'> cog.outl("This is line two")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This is line one</p>
-<p class='pln'> </p>
-<p class='pln'> This is line two</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> epilogue.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), outfile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testEmptyCog(self):</p>
-<p class='pln'> # The cog clause can be totally empty. Not sure why you'd want it,</p>
-<p class='pln'> # but it works.</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> hello</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> goodbye</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testMultipleCogs(self):</p>
-<p class='pln'> # One file can have many cog chunks, even abutting each other.</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.out("chunk1")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> chunk1</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.out("chunk2")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> chunk2</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> between chunks</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.out("chunk3")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> chunk3</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTrimBlankLines(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.out("This is line one\\n", trimblanklines=True)</p>
-<p class='pln'> cog.out('''</p>
-<p class='pln'> This is line two</p>
-<p class='pln'> ''', dedent=True, trimblanklines=True)</p>
-<p class='pln'> cog.outl("This is line three", trimblanklines=True)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This is line one</p>
-<p class='pln'> This is line two</p>
-<p class='pln'> This is line three</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTrimEmptyBlankLines(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.out("This is line one\\n", trimblanklines=True)</p>
-<p class='pln'> cog.out('''</p>
-<p class='pln'> This is line two</p>
-<p class='pln'> ''', dedent=True, trimblanklines=True)</p>
-<p class='pln'> cog.out('', dedent=True, trimblanklines=True)</p>
-<p class='pln'> cog.outl("This is line three", trimblanklines=True)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This is line one</p>
-<p class='pln'> This is line two</p>
-<p class='pln'> This is line three</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def test22EndOfLine(self):</p>
-<p class='pln'> # In Python 2.2, this cog file was not parsing because the</p>
-<p class='pln'> # last line is indented but didn't end with a newline.</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import cog</p>
-<p class='pln'> for i in range(3):</p>
-<p class='pln'> cog.out("%d\\n" % i)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> 0</p>
-<p class='pln'> 1</p>
-<p class='pln'> 2</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testIndentedCode(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> first line</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> import cog</p>
-<p class='pln'> for i in range(3):</p>
-<p class='pln'> cog.out("xx%d\\n" % i)</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> xx0</p>
-<p class='pln'> xx1</p>
-<p class='pln'> xx2</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> last line</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testPrefixedCode(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> --[[[cog</p>
-<p class='pln'> --import cog</p>
-<p class='pln'> --for i in range(3):</p>
-<p class='pln'> -- cog.out("xx%d\\n" % i)</p>
-<p class='pln'> --]]]</p>
-<p class='pln'> xx0</p>
-<p class='pln'> xx1</p>
-<p class='pln'> xx2</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testPrefixedIndentedCode(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> prologue</p>
-<p class='pln'> --[[[cog</p>
-<p class='pln'> -- import cog</p>
-<p class='pln'> -- for i in range(3):</p>
-<p class='pln'> -- cog.out("xy%d\\n" % i)</p>
-<p class='pln'> --]]]</p>
-<p class='pln'> xy0</p>
-<p class='pln'> xy1</p>
-<p class='pln'> xy2</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testBogusPrefixMatch(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> prologue</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> import cog</p>
-<p class='pln'> # This comment should not be clobbered by removing the pound sign.</p>
-<p class='pln'> for i in range(3):</p>
-<p class='pln'> cog.out("xy%d\\n" % i)</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> xy0</p>
-<p class='pln'> xy1</p>
-<p class='pln'> xy2</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoFinalNewline(self):</p>
-<p class='pln'> # If the cog'ed output has no final newline,</p>
-<p class='pln'> # it shouldn't eat up the cog terminator.</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> prologue</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> import cog</p>
-<p class='pln'> for i in range(3):</p>
-<p class='pln'> cog.out("%d" % i)</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> 012</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> epilogue</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoOutputAtAll(self):</p>
-<p class='pln'> # If there is absolutely no cog output, that's ok.</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> prologue</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> i = 1</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> epilogue</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testPurelyBlankLine(self):</p>
-<p class='pln'> # If there is a blank line in the cog code with no whitespace</p>
-<p class='pln'> # prefix, that should be OK.</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> prologue</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> import sys</p>
-<p class='pln'> cog.out("Hello")</p>
-<p class='pln'> $</p>
-<p class='pln'> cog.out("There")</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> HelloThere</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> epilogue</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile.replace('$', ''))</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testEmptyOutl(self):</p>
-<p class='pln'> # Alexander Belchenko suggested the string argument to outl should</p>
-<p class='pln'> # be optional. Does it work?</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> prologue</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> cog.outl("x")</p>
-<p class='pln'> cog.outl()</p>
-<p class='pln'> cog.outl("y")</p>
-<p class='pln'> cog.outl(trimblanklines=True)</p>
-<p class='pln'> cog.outl("z")</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> x</p>
-<p class='pln'> </p>
-<p class='pln'> y</p>
-<p class='pln'> </p>
-<p class='pln'> z</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> epilogue</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testFirstLineNum(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> fooey</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> cog.outl("started at line number %d" % cog.firstLineNum)</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> started at line number 2</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> blah blah</p>
-<p class='pln'> [[[cog</p>
-<p class='pln'> cog.outl("and again at line %d" % cog.firstLineNum)</p>
-<p class='pln'> ]]]</p>
-<p class='pln'> and again at line 8</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCompactOneLineCode(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> first line</p>
-<p class='pln'> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</p>
-<p class='pln'> get rid of this!</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> last line</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> outfile = """\</p>
-<p class='pln'> first line</p>
-<p class='pln'> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</p>
-<p class='pln'> hello 81</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> last line</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), reindentBlock(outfile))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testInsideOutCompact(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> first line</p>
-<p class='pln'> hey?: ]]] what is this? [[[cog strange!</p>
-<p class='pln'> get rid of this!</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> last line</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "infile.txt(2): Cog code markers inverted",</p>
-<p class='pln'> Cog().processString,</p>
-<p class='pln'> reindentBlock(infile), "infile.txt")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSharingGlobals(self):</p>
-<p class='stm run hide'> infile = """\</p>
-<p class='pln'> first line</p>
-<p class='pln'> hey: [[[cog s="hey there" ]]] looky!</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> more literal junk.</p>
-<p class='pln'> [[[cog cog.outl(s) ]]]</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> last line</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> outfile = """\</p>
-<p class='pln'> first line</p>
-<p class='pln'> hey: [[[cog s="hey there" ]]] looky!</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> more literal junk.</p>
-<p class='pln'> [[[cog cog.outl(s) ]]]</p>
-<p class='pln'> hey there</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> last line</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> infile = reindentBlock(infile)</p>
-<p class='stm run hide'> self.assertEqual(Cog().processString(infile), reindentBlock(outfile))</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogOptionsTests(TestCase):</p>
-<p class='pln'> """ Test the CogOptions class.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testEquality(self):</p>
-<p class='stm mis'> o = CogOptions()</p>
-<p class='stm mis'> p = CogOptions()</p>
-<p class='stm mis'> self.assertEqual(o, p)</p>
-<p class='stm mis'> o.parseArgs(['-r'])</p>
-<p class='stm mis'> self.assertNotEqual(o, p)</p>
-<p class='stm mis'> p.parseArgs(['-r'])</p>
-<p class='stm mis'> self.assertEqual(o, p)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCloning(self):</p>
-<p class='stm mis'> o = CogOptions()</p>
-<p class='stm mis'> o.parseArgs(['-I', 'fooey', '-I', 'booey', '-s', ' /*x*/'])</p>
-<p class='stm mis'> p = o.clone()</p>
-<p class='stm mis'> self.assertEqual(o, p)</p>
-<p class='stm mis'> p.parseArgs(['-I', 'huey', '-D', 'foo=quux'])</p>
-<p class='stm mis'> self.assertNotEqual(o, p)</p>
-<p class='stm mis'> q = CogOptions()</p>
-<p class='stm mis'> q.parseArgs(['-I', 'fooey', '-I', 'booey', '-s', ' /*x*/', '-I', 'huey', '-D', 'foo=quux'])</p>
-<p class='stm mis'> self.assertEqual(p, q)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCombiningFlags(self):</p>
-<p class='pln'> # Single-character flags can be combined.</p>
-<p class='stm mis'> o = CogOptions()</p>
-<p class='stm mis'> o.parseArgs(['-e', '-r', '-z'])</p>
-<p class='stm mis'> p = CogOptions()</p>
-<p class='stm mis'> p.parseArgs(['-erz'])</p>
-<p class='stm mis'> self.assertEqual(o, p)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class FileStructureTests(TestCase):</p>
-<p class='pln'> """ Test cases to check that we're properly strict about the structure</p>
-<p class='pln'> of files.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def isBad(self, infile, msg=None):</p>
-<p class='stm mis'> infile = reindentBlock(infile)</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> msg,</p>
-<p class='pln'> Cog().processString, (infile), 'infile.txt')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testBeginNoEnd(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> Fooey</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('hello')</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(2): Cog block begun but never ended.")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoEoo(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> Fooey</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('hello')</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(4): Missing '[[[end]]]' before end of file.")</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile2 = """\</p>
-<p class='pln'> Fooey</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('hello')</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('goodbye')</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile2, "infile.txt(5): Unexpected '[[[cog'")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testStartWithEnd(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(1): Unexpected ']]]'")</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile2 = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('hello')</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile2, "infile.txt(5): Unexpected ']]]'")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testStartWithEoo(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(1): Unexpected '[[[end]]]'")</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile2 = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('hello')</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile2, "infile.txt(5): Unexpected '[[[end]]]'")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoEnd(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(3): Unexpected '[[[end]]]'")</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile2 = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl('hello')</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile2, "infile.txt(7): Unexpected '[[[end]]]'")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTwoBegins(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(2): Unexpected '[[[cog'")</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile2 = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile2, "infile.txt(6): Unexpected '[[[cog'")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTwoEnds(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile, "infile.txt(4): Unexpected ']]]'")</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile2 = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.outl("hello")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.isBad(infile2, "infile.txt(8): Unexpected ']]]'")</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogErrorTests(TestCase):</p>
-<p class='pln'> """ Test cases for cog.error().</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testErrorMsg(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> [[[cog cog.error("This ain't right!")]]]</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile = reindentBlock(infile)</p>
-<p class='stm mis'> self.assertRaisesMsg(CogGeneratedError,</p>
-<p class='pln'> "This ain't right!",</p>
-<p class='pln'> Cog().processString, (infile))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testErrorNoMsg(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> [[[cog cog.error()]]]</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile = reindentBlock(infile)</p>
-<p class='stm mis'> self.assertRaisesMsg(CogGeneratedError,</p>
-<p class='pln'> "Error raised by cog generator.",</p>
-<p class='pln'> Cog().processString, (infile))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoErrorIfErrorNotCalled(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> --[[[cog</p>
-<p class='pln'> --import cog</p>
-<p class='pln'> --for i in range(3):</p>
-<p class='pln'> -- if i > 10:</p>
-<p class='pln'> -- cog.error("Something is amiss!")</p>
-<p class='pln'> -- cog.out("xx%d\\n" % i)</p>
-<p class='pln'> --]]]</p>
-<p class='pln'> xx0</p>
-<p class='pln'> xx1</p>
-<p class='pln'> xx2</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm mis'> infile = reindentBlock(infile)</p>
-<p class='stm mis'> self.assertEqual(Cog().processString(infile), infile)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogGeneratorGetCodeTests(TestCase):</p>
-<p class='pln'> """ Unit tests against CogGenerator to see if its getCode() method works</p>
-<p class='pln'> properly.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def setUp(self):</p>
-<p class='pln'> """ All tests get a generator to use, and short same-length names for</p>
-<p class='pln'> the functions we're going to use.</p>
-<p class='pln'> """</p>
-<p class='stm mis'> self.gen = CogGenerator()</p>
-<p class='stm mis'> self.m = self.gen.parseMarker</p>
-<p class='stm mis'> self.l = self.gen.parseLine</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testEmpty(self):</p>
-<p class='stm mis'> self.m('// [[[cog')</p>
-<p class='stm mis'> self.m('// ]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), '')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSimple(self):</p>
-<p class='stm mis'> self.m('// [[[cog')</p>
-<p class='stm mis'> self.l(' print "hello"')</p>
-<p class='stm mis'> self.l(' print "bye"')</p>
-<p class='stm mis'> self.m('// ]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), 'print "hello"\nprint "bye"')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCompressed1(self):</p>
-<p class='pln'> # For a while, I supported compressed code blocks, but no longer.</p>
-<p class='stm mis'> self.m('// [[[cog: print """')</p>
-<p class='stm mis'> self.l('// hello')</p>
-<p class='stm mis'> self.l('// bye')</p>
-<p class='stm mis'> self.m('// """)]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), 'hello\nbye')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCompressed2(self):</p>
-<p class='pln'> # For a while, I supported compressed code blocks, but no longer.</p>
-<p class='stm mis'> self.m('// [[[cog: print """')</p>
-<p class='stm mis'> self.l('hello')</p>
-<p class='stm mis'> self.l('bye')</p>
-<p class='stm mis'> self.m('// """)]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), 'hello\nbye')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCompressed3(self):</p>
-<p class='pln'> # For a while, I supported compressed code blocks, but no longer.</p>
-<p class='stm mis'> self.m('// [[[cog')</p>
-<p class='stm mis'> self.l('print """hello')</p>
-<p class='stm mis'> self.l('bye')</p>
-<p class='stm mis'> self.m('// """)]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), 'print """hello\nbye')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCompressed4(self):</p>
-<p class='pln'> # For a while, I supported compressed code blocks, but no longer.</p>
-<p class='stm mis'> self.m('// [[[cog: print """')</p>
-<p class='stm mis'> self.l('hello')</p>
-<p class='stm mis'> self.l('bye""")')</p>
-<p class='stm mis'> self.m('// ]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), 'hello\nbye""")')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoCommonPrefixForMarkers(self):</p>
-<p class='pln'> # It's important to be able to use #if 0 to hide lines from a</p>
-<p class='pln'> # C++ compiler.</p>
-<p class='stm mis'> self.m('#if 0 //[[[cog')</p>
-<p class='stm mis'> self.l('\timport cog, sys')</p>
-<p class='stm mis'> self.l('')</p>
-<p class='stm mis'> self.l('\tprint sys.argv')</p>
-<p class='stm mis'> self.m('#endif //]]]')</p>
-<p class='stm mis'> self.assertEqual(self.gen.getCode(), 'import cog, sys\n\nprint sys.argv')</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class TestCaseWithTempDir(TestCase):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def newCog(self):</p>
-<p class='pln'> """ Initialize the cog members for another run.</p>
-<p class='pln'> """</p>
-<p class='pln'> # Create a cog engine, and catch its output.</p>
-<p class='stm mis'> self.cog = Cog()</p>
-<p class='stm mis'> self.output = StringIO.StringIO()</p>
-<p class='stm mis'> self.cog.setOutput(stdout=self.output, stderr=self.output)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def setUp(self):</p>
-<p class='pln'> # Create a temporary directory.</p>
-<p class='stm mis'> self.tempdir = path.path(tempfile.gettempdir()) / ('testcog_tempdir_' + str(random.random())[2:])</p>
-<p class='stm mis'> self.tempdir.mkdir()</p>
-<p class='stm mis'> self.olddir = os.getcwd()</p>
-<p class='stm mis'> os.chdir(self.tempdir)</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def tearDown(self):</p>
-<p class='stm mis'> os.chdir(self.olddir)</p>
-<p class='pln'> # Get rid of the temporary directory.</p>
-<p class='stm mis'> self.tempdir.rmtree()</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def assertFilesSame(self, sFName1, sFName2):</p>
-<p class='stm mis'> self.assertEqual((self.tempdir / sFName1).text(), (self.tempdir / sFName2).text())</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def assertFileContent(self, sFName, sContent):</p>
-<p class='stm mis'> sAbsName = self.tempdir / sFName</p>
-<p class='stm mis'> f = open(sAbsName, 'rb')</p>
-<p class='stm mis'> try:</p>
-<p class='stm mis'> sFileContent = f.read()</p>
-<p class='pln'> finally:</p>
-<p class='stm mis'> f.close()</p>
-<p class='stm mis'> self.assertEqual(sFileContent, sContent)</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class ArgumentHandlingTests(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testArgumentFailure(self):</p>
-<p class='pln'> # Return value 2 means usage problem.</p>
-<p class='stm mis'> assert(self.cog.main(['argv0', '-j']) == 2)</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("option -j not recognized") >= 0)</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0']))</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-j']))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNoDashOAndAtFile(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-o', 'foo', '@cogfiles.txt']))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testDashV(self):</p>
-<p class='stm mis'> assert(self.cog.main(['argv0', '-v']) == 0)</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> self.assertEqual('Cog version %s\n' % __version__, output)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def producesHelp(self, args):</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> argv = ['argv0'] + args.split()</p>
-<p class='stm mis'> assert(self.cog.main(argv) == 0)</p>
-<p class='stm mis'> self.assertEquals(usage, self.output.getvalue())</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testDashH(self):</p>
-<p class='pln'> # -h or -? anywhere on the command line should just print help.</p>
-<p class='stm mis'> self.producesHelp("-h")</p>
-<p class='stm mis'> self.producesHelp("-?")</p>
-<p class='stm mis'> self.producesHelp("fooey.txt -h")</p>
-<p class='stm mis'> self.producesHelp("-o -r @fooey.txt -? @booey.txt")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testDashOAndDashR(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cogfile.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-o', 'foo', '-r', 'cogfile.txt']))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testDashZ(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> void DoSomething();</p>
-<p class='pln'> void DoAnotherThing();</p>
-<p class='pln'> void DoLastThing();</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.assertRaisesMsg(</p>
-<p class='pln'> CogError, "test.cog(6): Missing '[[[end]]]' before end of file.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-r', 'test.cog']))</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-z', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testBadDashD(self):</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-Dfooey', 'cog.txt']))</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-D', 'fooey', 'cog.txt']))</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class TestFileHandling(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSimple(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> void DoSomething();</p>
-<p class='pln'> void DoAnotherThing();</p>
-<p class='pln'> void DoLastThing();</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("(changed)") >= 0)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testOutputFile(self):</p>
-<p class='pln'> # -o sets the output file.</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> void DoSomething();</p>
-<p class='pln'> void DoAnotherThing();</p>
-<p class='pln'> void DoLastThing();</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-o', 'test.cogged', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cogged', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testAtFile(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'one.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("hello world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'one.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("hello world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> hello world</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("goodbye cruel world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("goodbye cruel world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> goodbye cruel world</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> one.cog</p>
-<p class='pln'> </p>
-<p class='pln'> two.cog</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '@cogfiles.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('one.cog', 'one.out')</p>
-<p class='stm mis'> self.assertFilesSame('two.cog', 'two.out')</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("(changed)") >= 0)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNestedAtFile(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'one.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("hello world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'one.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("hello world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> hello world</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("goodbye cruel world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("goodbye cruel world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> goodbye cruel world</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> one.cog</p>
-<p class='pln'> @cogfiles2.txt</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles2.txt': """\</p>
-<p class='pln'> # This one too, please.</p>
-<p class='pln'> two.cog</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '@cogfiles.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('one.cog', 'one.out')</p>
-<p class='stm mis'> self.assertFilesSame('two.cog', 'two.out')</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("(changed)") >= 0)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testAtFileWithArgs(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'both.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("one: %s" % globals().has_key('one'))</p>
-<p class='pln'> cog.outl("two: %s" % globals().has_key('two'))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'one.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("one: %s" % globals().has_key('one'))</p>
-<p class='pln'> cog.outl("two: %s" % globals().has_key('two'))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> one: True // ONE</p>
-<p class='pln'> two: False // ONE</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("one: %s" % globals().has_key('one'))</p>
-<p class='pln'> cog.outl("two: %s" % globals().has_key('two'))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> one: False // TWO</p>
-<p class='pln'> two: True // TWO</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> both.cog -o both.one -s ' // ONE' -D one=x</p>
-<p class='pln'> both.cog -o both.two -s ' // TWO' -D two=x</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '@cogfiles.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('both.one', 'one.out')</p>
-<p class='stm mis'> self.assertFilesSame('both.two', 'two.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testAtFileWithBadArgCombo(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'both.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("one: %s" % globals().has_key('one'))</p>
-<p class='pln'> cog.outl("two: %s" % globals().has_key('two'))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> both.cog</p>
-<p class='pln'> both.cog -d # This is bad: -r and -d</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-r', '@cogfiles.txt']))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testAtFileWithTrickyFilenames(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'one 1.cog': """\</p>
-<p class='pln'> //[[[cog cog.outl("hello world") ]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'one.out': """\</p>
-<p class='pln'> //[[[cog cog.outl("hello world") ]]]</p>
-<p class='pln'> hello world //xxx</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'subdir': {</p>
-<p class='pln'> 'subback.cog': """\</p>
-<p class='pln'> //[[[cog cog.outl("down deep with backslashes") ]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'subfwd.cog': """\</p>
-<p class='pln'> //[[[cog cog.outl("down deep with slashes") ]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> },</p>
-<p class='pln'> </p>
-<p class='pln'> 'subback.out': """\</p>
-<p class='pln'> //[[[cog cog.outl("down deep with backslashes") ]]]</p>
-<p class='pln'> down deep with backslashes //yyy</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'subfwd.out': """\</p>
-<p class='pln'> //[[[cog cog.outl("down deep with slashes") ]]]</p>
-<p class='pln'> down deep with slashes //zzz</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> 'one 1.cog' -s ' //xxx'</p>
-<p class='pln'> subdir\subback.cog -s ' //yyy'</p>
-<p class='pln'> subdir/subfwd.cog -s ' //zzz'</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-z', '-r', '@cogfiles.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('one 1.cog', 'one.out')</p>
-<p class='stm mis'> self.assertFilesSame('subdir/subback.cog', 'subback.out')</p>
-<p class='stm mis'> self.assertFilesSame('subdir/subfwd.cog', 'subfwd.out')</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogTestLineEndings(TestCaseWithTempDir):</p>
-<p class='pln'> """Tests for -U option (force LF line-endings in output)."""</p>
-<p class='pln'> </p>
-<p class='stm run hide'> lines_in = ['Some text.',</p>
-<p class='pln'> '//[[[cog',</p>
-<p class='pln'> 'cog.outl("Cog text")',</p>
-<p class='pln'> '//]]]',</p>
-<p class='pln'> 'gobbledegook.',</p>
-<p class='pln'> '//[[[end]]]',</p>
-<p class='pln'> 'epilogue.',</p>
-<p class='pln'> '']</p>
-<p class='pln'> </p>
-<p class='stm run hide'> lines_out = ['Some text.',</p>
-<p class='pln'> '//[[[cog',</p>
-<p class='pln'> 'cog.outl("Cog text")',</p>
-<p class='pln'> '//]]]',</p>
-<p class='pln'> 'Cog text',</p>
-<p class='pln'> '//[[[end]]]',</p>
-<p class='pln'> 'epilogue.',</p>
-<p class='pln'> '']</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testOutputNativeEol(self):</p>
-<p class='stm mis'> makeFiles({'infile': '\n'.join(self.lines_in)})</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-o', 'outfile', 'infile'])</p>
-<p class='stm mis'> self.assertFileContent('outfile', os.linesep.join(self.lines_out))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testOutputLfEol(self):</p>
-<p class='stm mis'> makeFiles({'infile': '\n'.join(self.lines_in)})</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-U', '-o', 'outfile', 'infile'])</p>
-<p class='stm mis'> self.assertFileContent('outfile', '\n'.join(self.lines_out))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testReplaceNativeEol(self):</p>
-<p class='stm mis'> makeFiles({'test.cog': '\n'.join(self.lines_in)})</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'test.cog'])</p>
-<p class='stm mis'> self.assertFileContent('test.cog', os.linesep.join(self.lines_out))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testReplaceLfEol(self):</p>
-<p class='stm mis'> makeFiles({'test.cog': '\n'.join(self.lines_in)})</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-U', '-r', 'test.cog'])</p>
-<p class='stm mis'> self.assertFileContent('test.cog', '\n'.join(self.lines_out))</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class TestCaseWithImports(TestCaseWithTempDir):</p>
-<p class='pln'> """ When running tests which import modules, the sys.modules list</p>
-<p class='pln'> leaks from one test to the next. This test case class scrubs</p>
-<p class='pln'> the list after each run to keep the tests isolated from each other.</p>
-<p class='pln'> """</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def setUp(self):</p>
-<p class='stm mis'> TestCaseWithTempDir.setUp(self)</p>
-<p class='stm mis'> self.sysmodulekeys = list(sys.modules)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def tearDown(self):</p>
-<p class='stm mis'> modstoscrub = [</p>
-<p class='pln'> modname</p>
-<p class='pln'> for modname in sys.modules</p>
-<p class='pln'> if modname not in self.sysmodulekeys</p>
-<p class='pln'> ]</p>
-<p class='stm mis'> for modname in modstoscrub:</p>
-<p class='stm mis'> del sys.modules[modname]</p>
-<p class='stm mis'> TestCaseWithTempDir.tearDown(self)</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogIncludeTests(TestCaseWithImports):</p>
-<p class='stm run hide'> dincludes = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import mymodule</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import mymodule</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Hello from mymodule</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test2.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import mymodule</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Hello from mymodule in inc2</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'include': {</p>
-<p class='pln'> 'mymodule.py': """\</p>
-<p class='pln'> import cog</p>
-<p class='pln'> cog.outl("Hello from mymodule")</p>
-<p class='pln'> """</p>
-<p class='pln'> },</p>
-<p class='pln'> </p>
-<p class='pln'> 'inc2': {</p>
-<p class='pln'> 'mymodule.py': """\</p>
-<p class='pln'> import cog</p>
-<p class='pln'> cog.outl("Hello from mymodule in inc2")</p>
-<p class='pln'> """</p>
-<p class='pln'> },</p>
-<p class='pln'> </p>
-<p class='pln'> 'inc3': {</p>
-<p class='pln'> 'someothermodule.py': """\</p>
-<p class='pln'> import cog</p>
-<p class='pln'> cog.outl("This is some other module.")</p>
-<p class='pln'> """</p>
-<p class='pln'> },</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testNeedIncludePath(self):</p>
-<p class='pln'> # Try it without the -I, to see that an ImportError happens.</p>
-<p class='stm mis'> makeFiles(self.dincludes)</p>
-<p class='stm mis'> self.assertRaises(ImportError, self.cog.callableMain, (['argv0', '-r', 'test.cog']))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testIncludePath(self):</p>
-<p class='pln'> # Test that -I adds include directories properly.</p>
-<p class='stm mis'> makeFiles(self.dincludes)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-I', 'include', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTwoIncludePaths(self):</p>
-<p class='pln'> # Test that two -I's add include directories properly.</p>
-<p class='stm mis'> makeFiles(self.dincludes)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-I', 'include', '-I', 'inc2', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTwoIncludePaths2(self):</p>
-<p class='pln'> # Test that two -I's add include directories properly.</p>
-<p class='stm mis'> makeFiles(self.dincludes)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-I', 'inc2', '-I', 'include', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test2.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testUselessIncludePath(self):</p>
-<p class='pln'> # Test that the search will continue past the first directory.</p>
-<p class='stm mis'> makeFiles(self.dincludes)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-I', 'inc3', '-I', 'include', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSysPathIsUnchanged(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'bad.cog': """\</p>
-<p class='pln'> //[[[cog cog.error("Oh no!") ]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> 'good.cog': """\</p>
-<p class='pln'> //[[[cog cog.outl("Oh yes!") ]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='pln'> # Is it unchanged just by creating a cog engine?</p>
-<p class='stm mis'> oldsyspath = sys.path[:]</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> # Is it unchanged for a successful run?</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'good.cog'])</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> # Is it unchanged for a successful run with includes?</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-I', 'xyzzy', 'good.cog'])</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> # Is it unchanged for a successful run with two includes?</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-I', 'xyzzy', '-I', 'quux', 'good.cog'])</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> # Is it unchanged for a failed run?</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.assertRaises(CogError, self.cog.callableMain, (['argv0', '-r', 'bad.cog']))</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> # Is it unchanged for a failed run with includes?</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.assertRaises(CogError, self.cog.callableMain, (['argv0', '-r', '-I', 'xyzzy', 'bad.cog']))</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> # Is it unchanged for a failed run with two includes?</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.assertRaises(CogError, self.cog.callableMain, (['argv0', '-r', '-I', 'xyzzy', '-I', 'quux', 'bad.cog']))</p>
-<p class='stm mis'> self.assertEqual(oldsyspath, sys.path)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSubDirectories(self):</p>
-<p class='pln'> # Test that relative paths on the command line work, with includes.</p>
-<p class='pln'> </p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'code': {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import mysubmodule</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> import mysubmodule</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Hello from mysubmodule</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'mysubmodule.py': """\</p>
-<p class='pln'> import cog</p>
-<p class='pln'> cog.outl("Hello from mysubmodule")</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='pln'> # We should be able to invoke cog without the -I switch, and it will</p>
-<p class='pln'> # auto-include the current directory</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'code/test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('code/test.cog', 'code/test.out')</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='stm run hide'>class CogTestsInFiles(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testWarnIfNoCogCode(self):</p>
-<p class='pln'> # Test that the -e switch warns if there is no Cog code.</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'with.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("hello world")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> hello world</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'without.cog': """\</p>
-<p class='pln'> There's no cog</p>
-<p class='pln'> code in this file.</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-e', 'with.cog'])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("Warning") < 0)</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-e', 'without.cog'])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("Warning: no cog code found in without.cog") >= 0)</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', 'without.cog'])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("Warning") < 0)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testFileNameProps(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> this is cog1.txt in, cog1.txt out</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This is cog1.txt in, cog1.txt out</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1out.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This is cog1.txt in, cog1out.txt out</p>
-<p class='pln'> [[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out')</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-o', 'cog1out.txt', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1out.txt', 'cog1out.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testGlobalsDontCrossFiles(self):</p>
-<p class='pln'> # Make sure that global values don't get shared between files.</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'one.cog': """\</p>
-<p class='pln'> //[[[cog s = "This was set in one.cog" ]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> //[[[cog cog.outl(s) ]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'one.out': """\</p>
-<p class='pln'> //[[[cog s = "This was set in one.cog" ]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> //[[[cog cog.outl(s) ]]]</p>
-<p class='pln'> This was set in one.cog</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> try:</p>
-<p class='pln'> cog.outl(s)</p>
-<p class='pln'> except NameError:</p>
-<p class='pln'> cog.outl("s isn't set!")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'two.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> try:</p>
-<p class='pln'> cog.outl(s)</p>
-<p class='pln'> except NameError:</p>
-<p class='pln'> cog.outl("s isn't set!")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> s isn't set!</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cogfiles.txt': """\</p>
-<p class='pln'> # Please run cog</p>
-<p class='pln'> one.cog</p>
-<p class='pln'> </p>
-<p class='pln'> two.cog</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '@cogfiles.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('one.cog', 'one.out')</p>
-<p class='stm mis'> self.assertFilesSame('two.cog', 'two.out')</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> assert(output.find("(changed)") >= 0)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testRemoveGeneratedOutput(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was generated.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was generated.</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> This line was not.</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was generated.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> This line was not.</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1.out2': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was generated.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was generated.</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> This line was not.</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='pln'> # Remove generated output.</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-x', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out')</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='pln'> # Regenerate the generated output.</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out2')</p>
-<p class='stm mis'> self.newCog()</p>
-<p class='pln'> # Remove the generated output again.</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-x', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testMsgCall(self):</p>
-<p class='stm mis'> infile = """\</p>
-<p class='pln'> #[[[cog</p>
-<p class='pln'> cog.msg("Hello there!")</p>
-<p class='pln'> #]]]</p>
-<p class='pln'> #[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='stm mis'> infile = reindentBlock(infile)</p>
-<p class='stm mis'> self.assertEqual(self.cog.processString(infile), infile)</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> self.assertEqual(output, "Message: Hello there!\n")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testErrorMessageHasNoTraceback(self):</p>
-<p class='pln'> # Test that a Cog error is printed to stderr with no traceback.</p>
-<p class='pln'> </p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Xhis line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah.</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> stderr = StringIO.StringIO()</p>
-<p class='stm mis'> self.cog.setOutput(stderr=stderr)</p>
-<p class='stm mis'> self.cog.main(['argv0', '-c', '-r', "cog1.txt"])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> self.assertEqual(self.output.getvalue(), "Cogging cog1.txt\n")</p>
-<p class='stm mis'> self.assertEqual(stderr.getvalue(), "cog1.txt(9): Output has been edited! Delete old checksum to unprotect.\n")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testDashD(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.kablooey': """\</p>
-<p class='pln'> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</p>
-<p class='pln'> Defined fooey as kablooey</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.einstein': """\</p>
-<p class='pln'> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</p>
-<p class='pln'> Defined fooey as e=mc2</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-D', 'fooey=kablooey', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.kablooey')</p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-Dfooey=kablooey', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.kablooey')</p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-Dfooey=e=mc2', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.einstein')</p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-Dbar=quux', '-Dfooey=kablooey', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.kablooey')</p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-Dfooey=kablooey', '-Dbar=quux', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.kablooey')</p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-Dfooey=gooey', '-Dfooey=kablooey', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.kablooey')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testOutputToStdout(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> --[[[cog cog.outl('Hey there!') ]]]</p>
-<p class='pln'> --[[[end]]]</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> stderr = StringIO.StringIO()</p>
-<p class='stm mis'> self.cog.setOutput(stderr=stderr)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', 'test.cog'])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> outerr = stderr.getvalue()</p>
-<p class='stm mis'> self.assertEqual(output, "--[[[cog cog.outl('Hey there!') ]]]\nHey there!\n--[[[end]]]\n")</p>
-<p class='stm mis'> self.assertEqual(outerr, "")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSuffixOutputLines(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> Hey there.</p>
-<p class='pln'> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</p>
-<p class='pln'> ;[[[end]]]</p>
-<p class='pln'> Good bye.</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> Hey there.</p>
-<p class='pln'> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</p>
-<p class='pln'> a (foo)</p>
-<p class='pln'> b (foo)</p>
-<p class='pln'> </p>
-<p class='pln'> c (foo)</p>
-<p class='pln'> ;[[[end]]]</p>
-<p class='pln'> Good bye.</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-s', ' (foo)', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testEmptySuffix(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> ;[[[cog cog.outl('a\\nb\\nc') ]]]</p>
-<p class='pln'> ;[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> ;[[[cog cog.outl('a\\nb\\nc') ]]]</p>
-<p class='pln'> a</p>
-<p class='pln'> b</p>
-<p class='pln'> c</p>
-<p class='pln'> ;[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-s', '', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testHellishSuffix(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> ;[[[cog cog.outl('a\\n\\nb') ]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> ;[[[cog cog.outl('a\\n\\nb') ]]]</p>
-<p class='pln'> a /\\n*+([)]><</p>
-<p class='pln'> </p>
-<p class='pln'> b /\\n*+([)]><</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-z', '-r', '-s', r' /\n*+([)]><', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class WritabilityTests(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> void DoSomething();</p>
-<p class='pln'> void DoAnotherThing();</p>
-<p class='pln'> void DoLastThing();</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='exc'> if os.name == 'nt': # pragma: no cover</p>
-<p class='pln'> # for Windows</p>
-<p class='exc'> cmd_w_args = 'attrib -R %s'</p>
-<p class='exc'> cmd_w_asterisk = 'attrib -R *'</p>
-<p class='exc'> else: # pragma: no cover</p>
-<p class='pln'> # for unix-like</p>
-<p class='exc'> cmd_w_args = 'chmod +w %s'</p>
-<p class='exc'> cmd_w_asterisk = 'chmod +w *'</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def setUp(self):</p>
-<p class='stm mis'> TestCaseWithTempDir.setUp(self)</p>
-<p class='stm mis'> makeFiles(self.d)</p>
-<p class='stm mis'> self.testcog = self.tempdir / 'test.cog'</p>
-<p class='stm mis'> self.testcog.chmod(stat.S_IREAD) # Make the file readonly.</p>
-<p class='stm mis'> assert not os.access(self.testcog, os.W_OK)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def tearDown(self):</p>
-<p class='stm mis'> self.testcog.chmod(stat.S_IWRITE) # Make the file writable again.</p>
-<p class='stm mis'> TestCaseWithTempDir.tearDown(self)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testReadonlyNoCommand(self):</p>
-<p class='stm mis'> self.assertRaisesMsg(</p>
-<p class='pln'> CogError, "Can't overwrite test.cog",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-r', 'test.cog']))</p>
-<p class='stm mis'> assert not os.access(self.testcog, os.W_OK)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testReadonlyWithCommand(self):</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-w', self.cmd_w_args, 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='stm mis'> assert os.access(self.testcog, os.W_OK)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testReadonlyWithCommandWithNoSlot(self):</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-w', self.cmd_w_asterisk, 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cog', 'test.out')</p>
-<p class='stm mis'> assert os.access(self.testcog, os.W_OK)</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testReadonlyWithIneffectualCommand(self):</p>
-<p class='stm mis'> self.assertRaisesMsg(</p>
-<p class='pln'> CogError, "Couldn't make test.cog writable",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-r', '-w', 'echo %s', 'test.cog']))</p>
-<p class='stm mis'> assert not os.access(self.testcog, os.W_OK)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class ChecksumTests(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCreateChecksumOutput(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was generated.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was generated.</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> This line was not.</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was generated.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was generated.</p>
-<p class='pln'> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</p>
-<p class='pln'> This line was not.</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-c', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testCheckChecksumOutput(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was generated.</p>
-<p class='pln'> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah.</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', '-c', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testRemoveChecksumOutput(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was generated.</p>
-<p class='pln'> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893) fooey</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog1.out': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah.</p>
-<p class='pln'> //[[[end]]] fooey</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-r', 'cog1.txt'])</p>
-<p class='stm mis'> self.assertFilesSame('cog1.txt', 'cog1.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testTamperedChecksumOutput(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'cog1.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Xhis line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah.</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog2.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah!</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog3.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> </p>
-<p class='pln'> This line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah.</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog4.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah..</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog5.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> This line was newly</p>
-<p class='pln'> generated by cog</p>
-<p class='pln'> blah blah.</p>
-<p class='pln'> extra</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'cog6.txt': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.outl("This line was newly")</p>
-<p class='pln'> cog.outl("generated by cog")</p>
-<p class='pln'> cog.outl("blah blah.")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "cog1.txt(9): Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-c', "cog1.txt"]))</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "cog2.txt(9): Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-c', "cog2.txt"]))</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "cog3.txt(10): Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-c', "cog3.txt"]))</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "cog4.txt(9): Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-c', "cog4.txt"]))</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "cog5.txt(10): Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-c', "cog5.txt"]))</p>
-<p class='stm mis'> self.assertRaisesMsg(CogError,</p>
-<p class='pln'> "cog6.txt(6): Output has been edited! Delete old checksum to unprotect.",</p>
-<p class='pln'> self.cog.callableMain, (['argv0', '-c', "cog6.txt"]))</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class BlakeTests(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='pln'> # Blake Winton's contributions.</p>
-<p class='stm run hide'> def testDeleteCode(self):</p>
-<p class='pln'> # -o sets the output file.</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Some Sample Code Here</p>
-<p class='pln'> //[[[end]]]Data Data</p>
-<p class='pln'> And Some More</p>
-<p class='pln'> """,</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> void DoSomething();</p>
-<p class='pln'> void DoAnotherThing();</p>
-<p class='pln'> void DoLastThing();</p>
-<p class='pln'> And Some More</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.callableMain(['argv0', '-d', '-o', 'test.cogged', 'test.cog'])</p>
-<p class='stm mis'> self.assertFilesSame('test.cogged', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testDeleteCodeWithDashRFails(self):</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> """</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.assertRaises(CogUsageError, self.cog.callableMain, (['argv0', '-r', '-d', 'test.cog']))</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testSettingGlobals(self):</p>
-<p class='pln'> # Blake Winton contributed a way to set the globals that will be used in</p>
-<p class='pln'> # processFile().</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'test.cog': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> for fn in fnames:</p>
-<p class='pln'> cog.outl("void %s();" % fn)</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> Some Sample Code Here</p>
-<p class='pln'> //[[[end]]]""",</p>
-<p class='pln'> </p>
-<p class='pln'> 'test.out': """\</p>
-<p class='pln'> // This is my C++ file.</p>
-<p class='pln'> void DoBlake();</p>
-<p class='pln'> void DoWinton();</p>
-<p class='pln'> void DoContribution();</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> globals = {}</p>
-<p class='stm mis'> globals['fnames'] = ['DoBlake', 'DoWinton', 'DoContribution']</p>
-<p class='stm mis'> self.cog.options.bDeleteCode = True</p>
-<p class='stm mis'> self.cog.processFile('test.cog', 'test.cogged', globals=globals)</p>
-<p class='stm mis'> self.assertFilesSame('test.cogged', 'test.out')</p>
-<p class='pln'> </p>
-<p class='stm run hide'>class ErrorCallTests(TestCaseWithTempDir):</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testErrorCallHasNoTraceback(self):</p>
-<p class='pln'> # Test that cog.error() doesn't show a traceback.</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'error.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> cog.error("Something Bad!")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.main(['argv0', '-r', 'error.cog'])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> self.assertEqual(output, "Cogging error.cog\nError: Something Bad!\n")</p>
-<p class='pln'> </p>
-<p class='stm run hide'> def testRealErrorHasTraceback(self):</p>
-<p class='pln'> # Test that a genuine error does show a traceback.</p>
-<p class='stm mis'> d = {</p>
-<p class='pln'> 'error.cog': """\</p>
-<p class='pln'> //[[[cog</p>
-<p class='pln'> raise RuntimeError("Hey!")</p>
-<p class='pln'> //]]]</p>
-<p class='pln'> //[[[end]]]</p>
-<p class='pln'> """,</p>
-<p class='pln'> }</p>
-<p class='pln'> </p>
-<p class='stm mis'> makeFiles(d)</p>
-<p class='stm mis'> self.cog.main(['argv0', '-r', 'error.cog'])</p>
-<p class='stm mis'> output = self.output.getvalue()</p>
-<p class='stm mis'> msg = 'Actual output:\n' + output</p>
-<p class='stm mis'> self.assert_(output.startswith("Cogging error.cog\nTraceback (most recent"), msg)</p>
-<p class='stm mis'> self.assert_(output.find("RuntimeError: Hey!") > 0, msg)</p>
-<p class='pln'> </p>
-<p class='pln'> </p>
-<p class='exc'>if __name__ == '__main__': #pragma: no cover</p>
-<p class='exc'> unittest.main()</p>
-<p class='pln'> </p>
-<p class='pln'># Things not yet tested:</p>
-<p class='pln'># - A bad -w command (currently fails silently).</p>
+<p class='pln'><span class='str'>""" Test cogapp.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> http://nedbatchelder.com/code/cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Copyright 2004-2009, Ned Batchelder.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>"""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>unittest</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>os</span><span class='op'>,</span> <span class='nam'>random</span><span class='op'>,</span> <span class='nam'>re</span><span class='op'>,</span> <span class='nam'>StringIO</span><span class='op'>,</span> <span class='nam'>stat</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>,</span> <span class='nam'>tempfile</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>path</span> <span class='com'># Non-standard, from http://www.jorendorff.com/articles/python/path</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>cogapp</span> <span class='key'>import</span> <span class='nam'>Cog</span><span class='op'>,</span> <span class='nam'>CogOptions</span><span class='op'>,</span> <span class='nam'>CogGenerator</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>cogapp</span> <span class='key'>import</span> <span class='nam'>CogError</span><span class='op'>,</span> <span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>CogGeneratedError</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>cogapp</span> <span class='key'>import</span> <span class='nam'>usage</span><span class='op'>,</span> <span class='nam'>__version__</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>whiteutils</span> <span class='key'>import</span> <span class='nam'>reindentBlock</span><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>from</span> <span class='nam'>makefiles</span> <span class='key'>import</span> <span class='op'>*</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>TestCase</span><span class='op'>(</span><span class='nam'>unittest</span><span class='op'>.</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Base class for all Cog test cases. Adds utility methods I like.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>excClass</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>,</span> <span class='nam'>callableObj</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Just like unittest.TestCase.assertRaises,</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> but checks that the message is right too.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>callableObj</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>except</span> <span class='nam'>excClass</span><span class='op'>,</span> <span class='nam'>exc</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>excMsg</span> <span class='op'>=</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>exc</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>msg</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># No message provided: it passes.</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>return</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>elif</span> <span class='nam'>excMsg</span> <span class='op'>==</span> <span class='nam'>msg</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Message provided, and we got the right message: it passes.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>else</span><span class='op'>:</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Message provided, and it didn't match: fail!</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>raise</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>failureException</span><span class='op'>(</span><span class='str'>"Right exception, wrong message: got '%s' expected '%s'"</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>excMsg</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>else</span><span class='op'>:</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>if</span> <span class='nam'>hasattr</span><span class='op'>(</span><span class='nam'>excClass</span><span class='op'>,</span><span class='str'>'__name__'</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>excName</span> <span class='op'>=</span> <span class='nam'>excClass</span><span class='op'>.</span><span class='nam'>__name__</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>else</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>excName</span> <span class='op'>=</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>excClass</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>raise</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>failureException</span><span class='op'>(</span><span class='str'>"Expected to raise %s, didn't get an exception at all"</span> <span class='op'>%</span> <span class='nam'>excName</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogTestsInMemory</span><span class='op'>(</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Test cases for cogapp.Cog()</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoCog</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>strings</span> <span class='op'>=</span> <span class='op'>[</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>''</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>' '</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>' \t \t \tx'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'hello'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'the cat\nin the\nhat.'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'Horton\n\tHears A\n\t\tWho'</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>for</span> <span class='nam'>s</span> <span class='key'>in</span> <span class='nam'>strings</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>s</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSimple</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Some text.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is line one\\n")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is line two")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> gobbledegook.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> epilogue.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>outfile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Some text.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is line one\\n")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is line two")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line one</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line two</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> epilogue.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>outfile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testEmptyCog</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># The cog clause can be totally empty. Not sure why you'd want it,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># but it works.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hello</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> goodbye</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testMultipleCogs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># One file can have many cog chunks, even abutting each other.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("chunk1")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> chunk1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("chunk2")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> chunk2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> between chunks</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("chunk3")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> chunk3</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTrimBlankLines</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("This is line one\\n", trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out('''</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line two</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ''', dedent=True, trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is line three", trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line one</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line two</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line three</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTrimEmptyBlankLines</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("This is line one\\n", trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out('''</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line two</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ''', dedent=True, trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out('', dedent=True, trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is line three", trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line one</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line two</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is line three</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>test22EndOfLine</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># In Python 2.2, this cog file was not parsing because the</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># last line is indented but didn't end with a newline.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("%d\\n" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> 0</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> 1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> 2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testIndentedCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> first line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("xx%d\\n" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx0</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testPrefixedCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- cog.out("xx%d\\n" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx0</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testPrefixedIndentedCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> prologue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- cog.out("xy%d\\n" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xy0</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xy1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xy2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testBogusPrefixMatch</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> prologue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # This comment should not be clobbered by removing the pound sign.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("xy%d\\n" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xy0</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xy1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xy2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoFinalNewline</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If the cog'ed output has no final newline,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># it shouldn't eat up the cog terminator.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> prologue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("%d" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> 012</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> epilogue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoOutputAtAll</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If there is absolutely no cog output, that's ok.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> prologue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> i = 1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> epilogue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testPurelyBlankLine</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># If there is a blank line in the cog code with no whitespace</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># prefix, that should be OK.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> prologue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import sys</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("Hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> $</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.out("There")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> HelloThere</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> epilogue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='str'>'$'</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testEmptyOutl</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Alexander Belchenko suggested the string argument to outl should</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># be optional. Does it work?</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> prologue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("x")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl()</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("y")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl(trimblanklines=True)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("z")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> x</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='str'> y</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> z</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> epilogue</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testFirstLineNum</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("started at line number %d" % cog.firstLineNum)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> started at line number 2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("and again at line %d" % cog.firstLineNum)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> and again at line 8</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCompactOneLineCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> first line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> get rid of this!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>outfile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> first line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hey: [[[cog cog.outl("hello %d" % (3*3*3*3)) ]]] looky!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hello 81</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>outfile</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testInsideOutCompact</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> first line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hey?: ]]] what is this? [[[cog strange!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> get rid of this!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"infile.txt(2): Cog code markers inverted"</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>"infile.txt"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSharingGlobals</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> first line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hey: [[[cog s="hey there" ]]] looky!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> more literal junk.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog cog.outl(s) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>outfile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> first line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hey: [[[cog s="hey there" ]]] looky!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> more literal junk.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog cog.outl(s) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hey there</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> last line</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>outfile</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogOptionsTests</span><span class='op'>(</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Test the CogOptions class.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testEquality</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>p</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>o</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-r'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertNotEqual</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>p</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-r'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>p</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCloning</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>o</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'fooey'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'booey'</span><span class='op'>,</span> <span class='str'>'-s'</span><span class='op'>,</span> <span class='str'>' /*x*/'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span> <span class='op'>=</span> <span class='nam'>o</span><span class='op'>.</span><span class='nam'>clone</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>p</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'huey'</span><span class='op'>,</span> <span class='str'>'-D'</span><span class='op'>,</span> <span class='str'>'foo=quux'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertNotEqual</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>p</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>q</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>q</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'fooey'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'booey'</span><span class='op'>,</span> <span class='str'>'-s'</span><span class='op'>,</span> <span class='str'>' /*x*/'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'huey'</span><span class='op'>,</span> <span class='str'>'-D'</span><span class='op'>,</span> <span class='str'>'foo=quux'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>p</span><span class='op'>,</span> <span class='nam'>q</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCombiningFlags</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Single-character flags can be combined.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>o</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>o</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-e'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-z'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span> <span class='op'>=</span> <span class='nam'>CogOptions</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>p</span><span class='op'>.</span><span class='nam'>parseArgs</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'-erz'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>o</span><span class='op'>,</span> <span class='nam'>p</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>FileStructureTests</span><span class='op'>(</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Test cases to check that we're properly strict about the structure</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> of files.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>msg</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>,</span> <span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'infile.txt'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testBeginNoEnd</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('hello')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(2): Cog block begun but never ended."</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoEoo</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('hello')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(4): Missing '[[[end]]]' before end of file."</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile2</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('hello')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('goodbye')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile2</span><span class='op'>,</span> <span class='str'>"infile.txt(5): Unexpected '[[[cog'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testStartWithEnd</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(1): Unexpected ']]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile2</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('hello')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]] </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile2</span><span class='op'>,</span> <span class='str'>"infile.txt(5): Unexpected ']]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testStartWithEoo</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(1): Unexpected '[[[end]]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile2</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('hello')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile2</span><span class='op'>,</span> <span class='str'>"infile.txt(5): Unexpected '[[[end]]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoEnd</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(3): Unexpected '[[[end]]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile2</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl('hello')</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile2</span><span class='op'>,</span> <span class='str'>"infile.txt(7): Unexpected '[[[end]]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTwoBegins</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(2): Unexpected '[[[cog'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile2</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile2</span><span class='op'>,</span> <span class='str'>"infile.txt(6): Unexpected '[[[cog'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTwoEnds</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>,</span> <span class='str'>"infile.txt(4): Unexpected ']]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile2</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>isBad</span><span class='op'>(</span><span class='nam'>infile2</span><span class='op'>,</span> <span class='str'>"infile.txt(8): Unexpected ']]]'"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogErrorTests</span><span class='op'>(</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Test cases for cog.error().</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testErrorMsg</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog cog.error("This ain't right!")]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogGeneratedError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"This ain't right!"</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>,</span> <span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testErrorNoMsg</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[cog cog.error()]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogGeneratedError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"Error raised by cog generator."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>,</span> <span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoErrorIfErrorNotCalled</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --for i in range(3):</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- if i > 10:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- cog.error("Something is amiss!")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> -- cog.out("xx%d\\n" % i)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx0</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx1</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> xx2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogGeneratorGetCodeTests</span><span class='op'>(</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Unit tests against CogGenerator to see if its getCode() method works</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> properly.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>setUp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" All tests get a generator to use, and short same-length names for</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> the functions we're going to use.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span> <span class='op'>=</span> <span class='nam'>CogGenerator</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>parseMarker</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>parseLine</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testEmpty</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// [[[cog'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// ]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSimple</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// [[[cog'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>' print "hello"'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>' print "bye"'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// ]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'print "hello"\nprint "bye"'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCompressed1</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># For a while, I supported compressed code blocks, but no longer.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// [[[cog: print """'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'// hello'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'// bye'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// """)]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'hello\nbye'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCompressed2</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># For a while, I supported compressed code blocks, but no longer.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// [[[cog: print """'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'hello'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'bye'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// """)]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'hello\nbye'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCompressed3</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># For a while, I supported compressed code blocks, but no longer.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// [[[cog'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'print """hello'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'bye'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// """)]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'print """hello\nbye'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCompressed4</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># For a while, I supported compressed code blocks, but no longer.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// [[[cog: print """'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'hello'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'bye""")'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'// ]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'hello\nbye""")'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoCommonPrefixForMarkers</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># It's important to be able to use #if 0 to hide lines from a</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># C++ compiler.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'#if 0 //[[[cog'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'\timport cog, sys'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>''</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>l</span><span class='op'>(</span><span class='str'>'\tprint sys.argv'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>m</span><span class='op'>(</span><span class='str'>'#endif //]]]'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>gen</span><span class='op'>.</span><span class='nam'>getCode</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>'import cog, sys\n\nprint sys.argv'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>TestCaseWithTempDir</span><span class='op'>(</span><span class='nam'>TestCase</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>newCog</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Initialize the cog members for another run.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Create a cog engine, and catch its output.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span> <span class='op'>=</span> <span class='nam'>Cog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>StringIO</span><span class='op'>.</span><span class='nam'>StringIO</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>setOutput</span><span class='op'>(</span><span class='nam'>stdout</span><span class='op'>=</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>,</span> <span class='nam'>stderr</span><span class='op'>=</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>setUp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Create a temporary directory.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span> <span class='op'>=</span> <span class='nam'>path</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>(</span><span class='nam'>tempfile</span><span class='op'>.</span><span class='nam'>gettempdir</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>/</span> <span class='op'>(</span><span class='str'>'testcog_tempdir_'</span> <span class='op'>+</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>random</span><span class='op'>.</span><span class='nam'>random</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class='op'>[</span><span class='num'>2</span><span class='op'>:</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span><span class='op'>.</span><span class='nam'>mkdir</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>olddir</span> <span class='op'>=</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>getcwd</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>chdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>tearDown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>chdir</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>olddir</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Get rid of the temporary directory.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span><span class='op'>.</span><span class='nam'>rmtree</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sFName1</span><span class='op'>,</span> <span class='nam'>sFName2</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span> <span class='op'>/</span> <span class='nam'>sFName1</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>text</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span> <span class='op'>/</span> <span class='nam'>sFName2</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>text</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>assertFileContent</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>sFName</span><span class='op'>,</span> <span class='nam'>sContent</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sAbsName</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span> <span class='op'>/</span> <span class='nam'>sFName</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span> <span class='op'>=</span> <span class='nam'>open</span><span class='op'>(</span><span class='nam'>sAbsName</span><span class='op'>,</span> <span class='str'>'rb'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>try</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>sFileContent</span> <span class='op'>=</span> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>read</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>finally</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>f</span><span class='op'>.</span><span class='nam'>close</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>sFileContent</span><span class='op'>,</span> <span class='nam'>sContent</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>ArgumentHandlingTests</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testArgumentFailure</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Return value 2 means usage problem.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-j'</span><span class='op'>]</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>2</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"option -j not recognized"</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-j'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNoDashOAndAtFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'foo'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDashV</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-v'</span><span class='op'>]</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='str'>'Cog version %s\n'</span> <span class='op'>%</span> <span class='nam'>__version__</span><span class='op'>,</span> <span class='nam'>output</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>producesHelp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>argv</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>]</span> <span class='op'>+</span> <span class='nam'>args</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='nam'>argv</span><span class='op'>)</span> <span class='op'>==</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEquals</span><span class='op'>(</span><span class='nam'>usage</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDashH</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># -h or -? anywhere on the command line should just print help.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>producesHelp</span><span class='op'>(</span><span class='str'>"-h"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>producesHelp</span><span class='op'>(</span><span class='str'>"-?"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>producesHelp</span><span class='op'>(</span><span class='str'>"fooey.txt -h"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>producesHelp</span><span class='op'>(</span><span class='str'>"-o -r @fooey.txt -? @booey.txt"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDashOAndDashR</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfile.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'foo'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'cogfile.txt'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDashZ</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoSomething();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoAnotherThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoLastThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>CogError</span><span class='op'>,</span> <span class='str'>"test.cog(6): Missing '[[[end]]]' before end of file."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-z'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testBadDashD</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-Dfooey'</span><span class='op'>,</span> <span class='str'>'cog.txt'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-D'</span><span class='op'>,</span> <span class='str'>'fooey'</span><span class='op'>,</span> <span class='str'>'cog.txt'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>TestFileHandling</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSimple</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoSomething();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoAnotherThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoLastThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"(changed)"</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testOutputFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># -o sets the output file.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoSomething();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoAnotherThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoLastThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'test.cogged'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cogged'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testAtFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hello world</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("goodbye cruel world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("goodbye cruel world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> goodbye cruel world</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> one.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> two.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'one.cog'</span><span class='op'>,</span> <span class='str'>'one.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'two.cog'</span><span class='op'>,</span> <span class='str'>'two.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"(changed)"</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNestedAtFile</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hello world</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("goodbye cruel world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("goodbye cruel world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> goodbye cruel world</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> one.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> @cogfiles2.txt</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles2.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # This one too, please.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> two.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'one.cog'</span><span class='op'>,</span> <span class='str'>'one.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'two.cog'</span><span class='op'>,</span> <span class='str'>'two.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"(changed)"</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testAtFileWithArgs</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'both.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("one: %s" % globals().has_key('one'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("two: %s" % globals().has_key('two'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("one: %s" % globals().has_key('one'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("two: %s" % globals().has_key('two'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> one: True // ONE</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> two: False // ONE</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("one: %s" % globals().has_key('one'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("two: %s" % globals().has_key('two'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> one: False // TWO</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> two: True // TWO</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> both.cog -o both.one -s ' // ONE' -D one=x</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> both.cog -o both.two -s ' // TWO' -D two=x</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'both.one'</span><span class='op'>,</span> <span class='str'>'one.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'both.two'</span><span class='op'>,</span> <span class='str'>'two.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testAtFileWithBadArgCombo</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'both.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("one: %s" % globals().has_key('one'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("two: %s" % globals().has_key('two'))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> both.cog </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> both.cog -d # This is bad: -r and -d</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testAtFileWithTrickyFilenames</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one 1.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("hello world") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("hello world") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hello world //xxx</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'subdir'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'subback.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("down deep with backslashes") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'subfwd.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("down deep with slashes") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'subback.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("down deep with backslashes") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> down deep with backslashes //yyy</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'subfwd.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("down deep with slashes") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> down deep with slashes //zzz</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> 'one 1.cog' -s ' //xxx'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> subdir\subback.cog -s ' //yyy'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> subdir/subfwd.cog -s ' //zzz'</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-z'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'one 1.cog'</span><span class='op'>,</span> <span class='str'>'one.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'subdir/subback.cog'</span><span class='op'>,</span> <span class='str'>'subback.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'subdir/subfwd.cog'</span><span class='op'>,</span> <span class='str'>'subfwd.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogTestLineEndings</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"""Tests for -U option (force LF line-endings in output)."""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>lines_in</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'Some text.'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'//[[[cog'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog.outl("Cog text")'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'//]]]'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'gobbledegook.'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'//[[[end]]]'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'epilogue.'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>''</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>lines_out</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'Some text.'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'//[[[cog'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog.outl("Cog text")'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'//]]]'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'Cog text'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'//[[[end]]]'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'epilogue.'</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>''</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testOutputNativeEol</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='op'>{</span><span class='str'>'infile'</span><span class='op'>:</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_in</span><span class='op'>)</span><span class='op'>}</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'outfile'</span><span class='op'>,</span> <span class='str'>'infile'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFileContent</span><span class='op'>(</span><span class='str'>'outfile'</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>linesep</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_out</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testOutputLfEol</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='op'>{</span><span class='str'>'infile'</span><span class='op'>:</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_in</span><span class='op'>)</span><span class='op'>}</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-U'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'outfile'</span><span class='op'>,</span> <span class='str'>'infile'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFileContent</span><span class='op'>(</span><span class='str'>'outfile'</span><span class='op'>,</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_out</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testReplaceNativeEol</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='op'>{</span><span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_in</span><span class='op'>)</span><span class='op'>}</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFileContent</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>linesep</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_out</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testReplaceLfEol</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='op'>{</span><span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_in</span><span class='op'>)</span><span class='op'>}</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-U'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFileContent</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>lines_out</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>TestCaseWithImports</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" When running tests which import modules, the sys.modules list</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> leaks from one test to the next. This test case class scrubs</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> the list after each run to keep the tests isolated from each other.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>setUp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>TestCaseWithTempDir</span><span class='op'>.</span><span class='nam'>setUp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sysmodulekeys</span> <span class='op'>=</span> <span class='nam'>list</span><span class='op'>(</span><span class='nam'>sys</span><span class='op'>.</span><span class='nam'>modules</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>tearDown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>modstoscrub</span> <span class='op'>=</span> <span class='op'>[</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>modname</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>for</span> <span class='nam'>modname</span> <span class='key'>in</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>modules</span><span class="strut"> </span></p>
+<p class='pln'> <span class='key'>if</span> <span class='nam'>modname</span> <span class='key'>not</span> <span class='key'>in</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>sysmodulekeys</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>for</span> <span class='nam'>modname</span> <span class='key'>in</span> <span class='nam'>modstoscrub</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>del</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>modules</span><span class='op'>[</span><span class='nam'>modname</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>TestCaseWithTempDir</span><span class='op'>.</span><span class='nam'>tearDown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogIncludeTests</span><span class='op'>(</span><span class='nam'>TestCaseWithImports</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>dincludes</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import mymodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import mymodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Hello from mymodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test2.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import mymodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Hello from mymodule in inc2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'include'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'mymodule.py'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("Hello from mymodule")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'inc2'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'mymodule.py'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("Hello from mymodule in inc2")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'inc3'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'someothermodule.py'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is some other module.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testNeedIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Try it without the -I, to see that an ImportError happens.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>dincludes</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>ImportError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that -I adds include directories properly.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>dincludes</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'include'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTwoIncludePaths</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that two -I's add include directories properly.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>dincludes</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'include'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'inc2'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTwoIncludePaths2</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that two -I's add include directories properly.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>dincludes</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'inc2'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'include'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test2.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testUselessIncludePath</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that the search will continue past the first directory.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>dincludes</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'inc3'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'include'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSysPathIsUnchanged</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'bad.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.error("Oh no!") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'good.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl("Oh yes!") ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged just by creating a cog engine?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>oldsyspath</span> <span class='op'>=</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>[</span><span class='op'>:</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged for a successful run?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'good.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged for a successful run with includes?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'xyzzy'</span><span class='op'>,</span> <span class='str'>'good.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged for a successful run with two includes?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'xyzzy'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'quux'</span><span class='op'>,</span> <span class='str'>'good.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged for a failed run?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'bad.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged for a failed run with includes?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'xyzzy'</span><span class='op'>,</span> <span class='str'>'bad.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Is it unchanged for a failed run with two includes?</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'xyzzy'</span><span class='op'>,</span> <span class='str'>'-I'</span><span class='op'>,</span> <span class='str'>'quux'</span><span class='op'>,</span> <span class='str'>'bad.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>oldsyspath</span><span class='op'>,</span> <span class='nam'>sys</span><span class='op'>.</span><span class='nam'>path</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSubDirectories</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that relative paths on the command line work, with includes.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'code'</span><span class='op'>:</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import mysubmodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import mysubmodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Hello from mysubmodule</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'mysubmodule.py'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> import cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("Hello from mysubmodule")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># We should be able to invoke cog without the -I switch, and it will</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># auto-include the current directory</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'code/test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'code/test.cog'</span><span class='op'>,</span> <span class='str'>'code/test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>CogTestsInFiles</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testWarnIfNoCogCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that the -e switch warns if there is no Cog code.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'with.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("hello world")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> hello world</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'without.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> There's no cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> code in this file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-e'</span><span class='op'>,</span> <span class='str'>'with.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"Warning"</span><span class='op'>)</span> <span class='op'><</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-e'</span><span class='op'>,</span> <span class='str'>'without.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"Warning: no cog code found in without.cog"</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'without.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"Warning"</span><span class='op'>)</span> <span class='op'><</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testFileNameProps</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> this is cog1.txt in, cog1.txt out</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is cog1.txt in, cog1.txt out</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1out.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This is %s in, %s out" % (cog.inFile, cog.outFile))</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This is cog1.txt in, cog1out.txt out</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> [[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'cog1out.txt'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1out.txt'</span><span class='op'>,</span> <span class='str'>'cog1out.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testGlobalsDontCrossFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Make sure that global values don't get shared between files.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog s = "This was set in one.cog" ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl(s) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'one.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog s = "This was set in one.cog" ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog cog.outl(s) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This was set in one.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> try:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl(s)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> except NameError:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("s isn't set!")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'two.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> try:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl(s)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> except NameError:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("s isn't set!")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> s isn't set!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cogfiles.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> # Please run cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> one.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> two.cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'@cogfiles.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'one.cog'</span><span class='op'>,</span> <span class='str'>'one.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'two.cog'</span><span class='op'>,</span> <span class='str'>'two.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"(changed)"</span><span class='op'>)</span> <span class='op'>>=</span> <span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testRemoveGeneratedOutput</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was generated.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was generated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was not.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was generated.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was not.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.out2'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was generated.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was generated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was not.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Remove generated output.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-x'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Regenerate the generated output.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out2'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>newCog</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Remove the generated output again.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-x'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testMsgCall</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.msg("Hello there!")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> #[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>infile</span> <span class='op'>=</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>processString</span><span class='op'>(</span><span class='nam'>infile</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>infile</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>,</span> <span class='str'>"Message: Hello there!\n"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testErrorMessageHasNoTraceback</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that a Cog error is printed to stderr with no traceback.</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Xhis line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>stderr</span> <span class='op'>=</span> <span class='nam'>StringIO</span><span class='op'>.</span><span class='nam'>StringIO</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>setOutput</span><span class='op'>(</span><span class='nam'>stderr</span><span class='op'>=</span><span class='nam'>stderr</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>"cog1.txt"</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>"Cogging cog1.txt\n"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class='op'>,</span> <span class='str'>"cog1.txt(9): Output has been edited! Delete old checksum to unprotect.\n"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDashD</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.kablooey'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Defined fooey as kablooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.einstein'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog cog.outl("Defined fooey as " + fooey) ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Defined fooey as e=mc2</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-D'</span><span class='op'>,</span> <span class='str'>'fooey=kablooey'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.kablooey'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-Dfooey=kablooey'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.kablooey'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-Dfooey=e=mc2'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.einstein'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-Dbar=quux'</span><span class='op'>,</span> <span class='str'>'-Dfooey=kablooey'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.kablooey'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-Dfooey=kablooey'</span><span class='op'>,</span> <span class='str'>'-Dbar=quux'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.kablooey'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-Dfooey=gooey'</span><span class='op'>,</span> <span class='str'>'-Dfooey=kablooey'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.kablooey'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testOutputToStdout</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[cog cog.outl('Hey there!') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> --[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>stderr</span> <span class='op'>=</span> <span class='nam'>StringIO</span><span class='op'>.</span><span class='nam'>StringIO</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>setOutput</span><span class='op'>(</span><span class='nam'>stderr</span><span class='op'>=</span><span class='nam'>stderr</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>outerr</span> <span class='op'>=</span> <span class='nam'>stderr</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>,</span> <span class='str'>"--[[[cog cog.outl('Hey there!') ]]]\nHey there!\n--[[[end]]]\n"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>outerr</span><span class='op'>,</span> <span class='str'>""</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSuffixOutputLines</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Hey there.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Good bye.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Hey there.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[cog cog.outl('a\\nb\\n \\nc') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> a (foo)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> b (foo)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> c (foo)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Good bye.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-s'</span><span class='op'>,</span> <span class='str'>' (foo)'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testEmptySuffix</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[cog cog.outl('a\\nb\\nc') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[cog cog.outl('a\\nb\\nc') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> a</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> b</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> c</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-s'</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testHellishSuffix</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[cog cog.outl('a\\n\\nb') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> ;[[[cog cog.outl('a\\n\\nb') ]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> a /\\n*+([)]><</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> b /\\n*+([)]><</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-z'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-s'</span><span class='op'>,</span> <span class='str'>r' /\n*+([)]><'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>WritabilityTests</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in ['DoSomething', 'DoAnotherThing', 'DoLastThing']:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoSomething();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoAnotherThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoLastThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>if</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>name</span> <span class='op'>==</span> <span class='str'>'nt'</span><span class='op'>:</span> <span class='com'># pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># for Windows</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>cmd_w_args</span> <span class='op'>=</span> <span class='str'>'attrib -R %s'</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>cmd_w_asterisk</span> <span class='op'>=</span> <span class='str'>'attrib -R *'</span><span class="strut"> </span></p>
+<p class='exc'> <span class='key'>else</span><span class='op'>:</span> <span class='com'># pragma: no cover</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># for unix-like</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>cmd_w_args</span> <span class='op'>=</span> <span class='str'>'chmod +w %s'</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>cmd_w_asterisk</span> <span class='op'>=</span> <span class='str'>'chmod +w *'</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>setUp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>TestCaseWithTempDir</span><span class='op'>.</span><span class='nam'>setUp</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>tempdir</span> <span class='op'>/</span> <span class='str'>'test.cog'</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>.</span><span class='nam'>chmod</span><span class='op'>(</span><span class='nam'>stat</span><span class='op'>.</span><span class='nam'>S_IREAD</span><span class='op'>)</span> <span class='com'># Make the file readonly.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span> <span class='key'>not</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>tearDown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>.</span><span class='nam'>chmod</span><span class='op'>(</span><span class='nam'>stat</span><span class='op'>.</span><span class='nam'>S_IWRITE</span><span class='op'>)</span> <span class='com'># Make the file writable again.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>TestCaseWithTempDir</span><span class='op'>.</span><span class='nam'>tearDown</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testReadonlyNoCommand</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>CogError</span><span class='op'>,</span> <span class='str'>"Can't overwrite test.cog"</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span> <span class='key'>not</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testReadonlyWithCommand</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-w'</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cmd_w_args</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testReadonlyWithCommandWithNoSlot</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-w'</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cmd_w_asterisk</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testReadonlyWithIneffectualCommand</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>CogError</span><span class='op'>,</span> <span class='str'>"Couldn't make test.cog writable"</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-w'</span><span class='op'>,</span> <span class='str'>'echo %s'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>assert</span> <span class='key'>not</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>access</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>testcog</span><span class='op'>,</span> <span class='nam'>os</span><span class='op'>.</span><span class='nam'>W_OK</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>ChecksumTests</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCreateChecksumOutput</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was generated.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was generated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was not.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was generated.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was generated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was not.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testCheckChecksumOutput</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was generated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testRemoveChecksumOutput</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was generated.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: 8adb13fb59b996a1c7f0065ea9f3d893) fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] fooey</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'cog1.txt'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'cog1.txt'</span><span class='op'>,</span> <span class='str'>'cog1.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testTamperedChecksumOutput</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog1.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Xhis line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog2.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah!</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog3.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog4.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah..</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog5.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> This line was newly</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> generated by cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> blah blah.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> extra</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'cog6.txt'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("This line was newly")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("generated by cog")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("blah blah.")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]] (checksum: a8540982e5ad6b95c9e9a184b26f4346)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"cog1.txt(9): Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>"cog1.txt"</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"cog2.txt(9): Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>"cog2.txt"</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"cog3.txt(10): Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>"cog3.txt"</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"cog4.txt(9): Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>"cog4.txt"</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"cog5.txt(10): Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>"cog5.txt"</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaisesMsg</span><span class='op'>(</span><span class='nam'>CogError</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>"cog6.txt(6): Output has been edited! Delete old checksum to unprotect."</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-c'</span><span class='op'>,</span> <span class='str'>"cog6.txt"</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>BlakeTests</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Blake Winton's contributions. </span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDeleteCode</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># -o sets the output file.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> fnames = ['DoSomething', 'DoAnotherThing', 'DoLastThing']</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Some Sample Code Here</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]Data Data</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> And Some More</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoSomething();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoAnotherThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoLastThing();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> And Some More</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-d'</span><span class='op'>,</span> <span class='str'>'-o'</span><span class='op'>,</span> <span class='str'>'test.cogged'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cogged'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testDeleteCodeWithDashRFails</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertRaises</span><span class='op'>(</span><span class='nam'>CogUsageError</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>callableMain</span><span class='op'>,</span> <span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'-d'</span><span class='op'>,</span> <span class='str'>'test.cog'</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testSettingGlobals</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Blake Winton contributed a way to set the globals that will be used in</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># processFile().</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> for fn in fnames:</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.outl("void %s();" % fn)</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Some Sample Code Here</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]"""</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'test.out'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> // This is my C++ file.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoBlake();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoWinton();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> void DoContribution();</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>globals</span> <span class='op'>=</span> <span class='op'>{</span><span class='op'>}</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>globals</span><span class='op'>[</span><span class='str'>'fnames'</span><span class='op'>]</span> <span class='op'>=</span> <span class='op'>[</span><span class='str'>'DoBlake'</span><span class='op'>,</span> <span class='str'>'DoWinton'</span><span class='op'>,</span> <span class='str'>'DoContribution'</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>options</span><span class='op'>.</span><span class='nam'>bDeleteCode</span> <span class='op'>=</span> <span class='nam'>True</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>processFile</span><span class='op'>(</span><span class='str'>'test.cog'</span><span class='op'>,</span> <span class='str'>'test.cogged'</span><span class='op'>,</span> <span class='nam'>globals</span><span class='op'>=</span><span class='nam'>globals</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertFilesSame</span><span class='op'>(</span><span class='str'>'test.cogged'</span><span class='op'>,</span> <span class='str'>'test.out'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>class</span> <span class='nam'>ErrorCallTests</span><span class='op'>(</span><span class='nam'>TestCaseWithTempDir</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testErrorCallHasNoTraceback</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that cog.error() doesn't show a traceback.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'error.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> cog.error("Something Bad!")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'error.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assertEqual</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>,</span> <span class='str'>"Cogging error.cog\nError: Something Bad!\n"</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>def</span> <span class='nam'>testRealErrorHasTraceback</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Test that a genuine error does show a traceback.</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>d</span> <span class='op'>=</span> <span class='op'>{</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>'error.cog'</span><span class='op'>:</span> <span class='str'>"""\</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> raise RuntimeError("Hey!")</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> //[[[end]]]</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class='op'>,</span><span class="strut"> </span></p>
+<p class='pln'> <span class='op'>}</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>makeFiles</span><span class='op'>(</span><span class='nam'>d</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>cog</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='op'>[</span><span class='str'>'argv0'</span><span class='op'>,</span> <span class='str'>'-r'</span><span class='op'>,</span> <span class='str'>'error.cog'</span><span class='op'>]</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>output</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>getvalue</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>msg</span> <span class='op'>=</span> <span class='str'>'Actual output:\n'</span> <span class='op'>+</span> <span class='nam'>output</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assert_</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>startswith</span><span class='op'>(</span><span class='str'>"Cogging error.cog\nTraceback (most recent"</span><span class='op'>)</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>assert_</span><span class='op'>(</span><span class='nam'>output</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='str'>"RuntimeError: Hey!"</span><span class='op'>)</span> <span class='op'>></span> <span class='num'>0</span><span class='op'>,</span> <span class='nam'>msg</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='exc'><span class='key'>if</span> <span class='nam'>__name__</span> <span class='op'>==</span> <span class='str'>'__main__'</span><span class='op'>:</span> <span class='com'>#pragma: no cover</span><span class="strut"> </span></p>
+<p class='exc'> <span class='nam'>unittest</span><span class='op'>.</span><span class='nam'>main</span><span class='op'>(</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'><span class='com'># Things not yet tested:</span><span class="strut"> </span></p>
+<p class='pln'><span class='com'># - A bad -w command (currently fails silently).</span><span class="strut"> </span></p>
</td>
</tr>
diff --git a/doc/sample_html/cogapp_whiteutils.html b/doc/sample_html/cogapp_whiteutils.html index e5f8435..b2aaf86 100644 --- a/doc/sample_html/cogapp_whiteutils.html +++ b/doc/sample_html/cogapp_whiteutils.html @@ -103,69 +103,69 @@ function toggle_lines(btn, cls) { </td>
<td class='text' valign='top'>
-<p class='pln'>""" Indentation utilities for Cog.</p>
-<p class='pln'> http://nedbatchelder.com/code/cog</p>
-<p class='pln'> </p>
-<p class='pln'> Copyright 2004-2009, Ned Batchelder.</p>
-<p class='pln'>"""</p>
-<p class='pln'> </p>
-<p class='stm run hide'>import re</p>
-<p class='pln'> </p>
-<p class='stm run hide'>def whitePrefix(strings):</p>
-<p class='pln'> """ Determine the whitespace prefix common to all non-blank lines</p>
-<p class='pln'> in the argument list.</p>
-<p class='pln'> """</p>
-<p class='pln'> # Remove all blank lines from the list</p>
-<p class='stm run hide'> strings = [s for s in strings if s.strip() != '']</p>
-<p class='pln'> </p>
-<p class='stm run hide'> if not strings: return ''</p>
-<p class='pln'> </p>
-<p class='pln'> # Find initial whitespace chunk in the first line.</p>
-<p class='pln'> # This is the best prefix we can hope for.</p>
-<p class='stm run hide'> prefix = re.match(r'\s*', strings[0]).group(0)</p>
-<p class='pln'> </p>
-<p class='pln'> # Loop over the other strings, keeping only as much of</p>
-<p class='pln'> # the prefix as matches each string.</p>
-<p class='stm run hide'> for s in strings:</p>
-<p class='stm run hide'> for i in range(len(prefix)):</p>
-<p class='stm run hide'> if prefix[i] != s[i]:</p>
-<p class='stm mis'> prefix = prefix[:i]</p>
-<p class='stm mis'> break</p>
-<p class='stm run hide'> return prefix</p>
-<p class='pln'> </p>
-<p class='stm run hide'>def reindentBlock(lines, newIndent=''):</p>
-<p class='pln'> """ Take a block of text as a string or list of lines.</p>
-<p class='pln'> Remove any common whitespace indentation.</p>
-<p class='pln'> Re-indent using newIndent, and return it as a single string.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> if isinstance(lines, basestring):</p>
-<p class='stm run hide'> lines = lines.split('\n')</p>
-<p class='stm run hide'> oldIndent = whitePrefix(lines)</p>
-<p class='stm run hide'> outLines = []</p>
-<p class='stm run hide'> for l in lines:</p>
-<p class='stm run hide'> if oldIndent:</p>
-<p class='stm run hide'> l = l.replace(oldIndent, '', 1)</p>
-<p class='stm run hide'> if l and newIndent:</p>
-<p class='stm run hide'> l = newIndent + l</p>
-<p class='stm run hide'> outLines.append(l)</p>
-<p class='stm run hide'> return '\n'.join(outLines)</p>
-<p class='pln'> </p>
-<p class='stm run hide'>def commonPrefix(strings):</p>
-<p class='pln'> """ Find the longest string that is a prefix of all the strings.</p>
-<p class='pln'> """</p>
-<p class='stm run hide'> if not strings:</p>
-<p class='stm mis'> return ''</p>
-<p class='stm run hide'> prefix = strings[0]</p>
-<p class='stm run hide'> for s in strings:</p>
-<p class='stm run hide'> if len(s) < len(prefix):</p>
-<p class='stm run hide'> prefix = prefix[:len(s)]</p>
-<p class='stm run hide'> if not prefix:</p>
-<p class='stm run hide'> return ''</p>
-<p class='stm run hide'> for i in range(len(prefix)):</p>
-<p class='stm run hide'> if prefix[i] != s[i]:</p>
-<p class='stm run hide'> prefix = prefix[:i]</p>
-<p class='stm run hide'> break</p>
-<p class='stm run hide'> return prefix</p>
+<p class='pln'><span class='str'>""" Indentation utilities for Cog.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> http://nedbatchelder.com/code/cog</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> </span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Copyright 2004-2009, Ned Batchelder.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'>"""</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>import</span> <span class='nam'>re</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>def</span> <span class='nam'>whitePrefix</span><span class='op'>(</span><span class='nam'>strings</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Determine the whitespace prefix common to all non-blank lines</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> in the argument list.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Remove all blank lines from the list</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>strings</span> <span class='op'>=</span> <span class='op'>[</span><span class='nam'>s</span> <span class='key'>for</span> <span class='nam'>s</span> <span class='key'>in</span> <span class='nam'>strings</span> <span class='key'>if</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>strip</span><span class='op'>(</span><span class='op'>)</span> <span class='op'>!=</span> <span class='str'>''</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>strings</span><span class='op'>:</span> <span class='key'>return</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Find initial whitespace chunk in the first line.</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># This is the best prefix we can hope for.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>prefix</span> <span class='op'>=</span> <span class='nam'>re</span><span class='op'>.</span><span class='nam'>match</span><span class='op'>(</span><span class='str'>r'\s*'</span><span class='op'>,</span> <span class='nam'>strings</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='num'>0</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># Loop over the other strings, keeping only as much of</span><span class="strut"> </span></p>
+<p class='pln'> <span class='com'># the prefix as matches each string.</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>for</span> <span class='nam'>s</span> <span class='key'>in</span> <span class='nam'>strings</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>for</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>range</span><span class='op'>(</span><span class='nam'>len</span><span class='op'>(</span><span class='nam'>prefix</span><span class='op'>)</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>prefix</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span> <span class='op'>!=</span> <span class='nam'>s</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='nam'>prefix</span> <span class='op'>=</span> <span class='nam'>prefix</span><span class='op'>[</span><span class='op'>:</span><span class='nam'>i</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>break</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>prefix</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>def</span> <span class='nam'>reindentBlock</span><span class='op'>(</span><span class='nam'>lines</span><span class='op'>,</span> <span class='nam'>newIndent</span><span class='op'>=</span><span class='str'>''</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Take a block of text as a string or list of lines.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Remove any common whitespace indentation.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> Re-indent using newIndent, and return it as a single string.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>lines</span><span class='op'>,</span> <span class='nam'>basestring</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>lines</span> <span class='op'>=</span> <span class='nam'>lines</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='str'>'\n'</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>oldIndent</span> <span class='op'>=</span> <span class='nam'>whitePrefix</span><span class='op'>(</span><span class='nam'>lines</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>outLines</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>for</span> <span class='nam'>l</span> <span class='key'>in</span> <span class='nam'>lines</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>oldIndent</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>l</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='nam'>oldIndent</span><span class='op'>,</span> <span class='str'>''</span><span class='op'>,</span> <span class='num'>1</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>l</span> <span class='key'>and</span> <span class='nam'>newIndent</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>newIndent</span> <span class='op'>+</span> <span class='nam'>l</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>outLines</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='str'>'\n'</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>outLines</span><span class='op'>)</span><span class="strut"> </span></p>
+<p class='pln'><span class="strut"> </span></p>
+<p class='stm run hide'><span class='key'>def</span> <span class='nam'>commonPrefix</span><span class='op'>(</span><span class='nam'>strings</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='pln'> <span class='str'>""" Find the longest string that is a prefix of all the strings.</span><span class="strut"> </span></p>
+<p class='pln'><span class='str'> """</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>strings</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm mis'> <span class='key'>return</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>prefix</span> <span class='op'>=</span> <span class='nam'>strings</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>for</span> <span class='nam'>s</span> <span class='key'>in</span> <span class='nam'>strings</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span> <span class='op'><</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>prefix</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>prefix</span> <span class='op'>=</span> <span class='nam'>prefix</span><span class='op'>[</span><span class='op'>:</span><span class='nam'>len</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>prefix</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='str'>''</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>for</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>range</span><span class='op'>(</span><span class='nam'>len</span><span class='op'>(</span><span class='nam'>prefix</span><span class='op'>)</span><span class='op'>)</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>if</span> <span class='nam'>prefix</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span> <span class='op'>!=</span> <span class='nam'>s</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span><span class='op'>:</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='nam'>prefix</span> <span class='op'>=</span> <span class='nam'>prefix</span><span class='op'>[</span><span class='op'>:</span><span class='nam'>i</span><span class='op'>]</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>break</span><span class="strut"> </span></p>
+<p class='stm run hide'> <span class='key'>return</span> <span class='nam'>prefix</span><span class="strut"> </span></p>
</td>
</tr>
diff --git a/doc/sample_html/index.html b/doc/sample_html/index.html index 478229a..c44d355 100644 --- a/doc/sample_html/index.html +++ b/doc/sample_html/index.html @@ -9,7 +9,7 @@ <div id='header'>
<div class='content'>
<h1>Coverage report:
- <span class='pc_cov'>44%</span>
+ <span class='pc_cov'>43%</span>
</h1>
</div>
</div>
@@ -25,6 +25,14 @@ </tr>
<tr>
+ <td class='name'><a href='_ned_py_path.html'>c:\ned\py\path</a></td>
+ <td>286</td>
+ <td>114</td>
+ <td>0</td>
+ <td>40%</td>
+</tr>
+
+<tr>
<td class='name'><a href='cogapp_cogapp.html'>cogapp\cogapp</a></td>
<td>387</td>
<td>219</td>
@@ -58,10 +66,10 @@ <tr class='total'>
<td class='name'>Total</td>
-<td>1040</td>
-<td>454</td>
+<td>1326</td>
+<td>568</td>
<td>23</td>
-<td>44%</td>
+<td>43%</td>
</tr>
</table>
</div>
@@ -69,7 +77,7 @@ <div id='footer'>
<div class='content'>
<p>
- <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage v3.0.1</a>
+ <a class='nav' href='http://nedbatchelder.com/code/coverage'>coverage.py v3.1</a>
</p>
</div>
</div>
diff --git a/doc/sample_html/style.css b/doc/sample_html/style.css index d9d324c..34ab10e 100644 --- a/doc/sample_html/style.css +++ b/doc/sample_html/style.css @@ -54,6 +54,11 @@ a.nav:hover { } #footer { + margin: 1em 3em; + } + +#footer .content { + padding: 0; font-size: 85%; font-family: verdana, sans-serif; color: #666666; @@ -65,7 +70,7 @@ a.nav:hover { } /* Header styles */ -.content { +#header .content { padding: 1em 3em; } @@ -124,6 +129,20 @@ td.text { background: inherit; } +/* Syntax coloring */ +.text .com { + color: green; + font-style: italic; + line-height: 1px; + } +.text .key { + font-weight: bold; + line-height: 1px; + } +.text .str { + color: #000080; + } + /* index styles */ #index td, #index th { text-align: right; |