<aname="L2"></a><ttclass="py-lineno"> 2</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># This file is part of pybliographer</tt></tt>
<aname="L7"></a><ttclass="py-lineno"> 7</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># This program is free software; you can redistribute it and/or</tt></tt>
<aname="L8"></a><ttclass="py-lineno"> 8</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># modify it under the terms of the GNU General Public License</tt></tt>
<aname="L9"></a><ttclass="py-lineno"> 9</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># as published by the Free Software Foundation; either version 2 </tt></tt>
<aname="L10"></a><ttclass="py-lineno"> 10</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># of the License, or (at your option) any later version.</tt></tt>
<aname="L12"></a><ttclass="py-lineno"> 12</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># This program is distributed in the hope that it will be useful,</tt></tt>
<aname="L13"></a><ttclass="py-lineno"> 13</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># but WITHOUT ANY WARRANTY; without even the implied warranty of</tt></tt>
<aname="L14"></a><ttclass="py-lineno"> 14</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</tt></tt>
<aname="L15"></a><ttclass="py-lineno"> 15</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># GNU General Public License for more details. </tt></tt>
<aname="L17"></a><ttclass="py-lineno"> 17</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># You should have received a copy of the GNU General Public License</tt></tt>
<aname="L18"></a><ttclass="py-lineno"> 18</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># along with this program; if not, write to the Free Software</tt></tt>
<aname="L19"></a><ttclass="py-lineno"> 19</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</tt></tt>
<aname="L25"></a><ttclass="py-lineno"> 25</tt><ttclass="py-line"><ttclass="py-docstring">This module defines the base syntax elements providing the formatting</tt></tt>
<aname="L26"></a><ttclass="py-lineno"> 26</tt><ttclass="py-line"><ttclass="py-docstring">domain specific language.</tt></tt>
</div><divid="_deferredText-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="_deferredText-expanded"><aname="L40"></a><ttclass="py-lineno"> 40</tt><ttclass="py-line"><ttclass="py-docstring">"""Ensure the parameter is a stage 1 object."""</tt></tt>
</div><divid="Glue-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="Glue-expanded"><aname="L47"></a><ttclass="py-lineno"> 47</tt><ttclass="py-line"><ttclass="py-docstring">""" A base class that known how to join together multiple</tt></tt>
<aname="L48"></a><ttclass="py-lineno"> 48</tt><ttclass="py-line"><ttclass="py-docstring"> fragments of DSL code."""</tt></tt>
</div><divid="_S1T-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="_S1T-expanded"><aname="L96"></a><ttclass="py-lineno"> 96</tt><ttclass="py-line"><ttclass="py-docstring">""" This is a stage 1 text, ie a text that returns a stage 2 text</tt></tt>
<aname="L97"></a><ttclass="py-lineno"> 97</tt><ttclass="py-line"><ttclass="py-docstring"> when called."""</tt></tt>
</div><divid="_Join-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="_Join-expanded"><aname="L114"></a><ttclass="py-lineno">114</tt><ttclass="py-line"><ttclass="py-docstring">""" The join operator is used to join together multiple fragments</tt></tt>
<aname="L115"></a><ttclass="py-lineno">115</tt><ttclass="py-line"><ttclass="py-docstring"> of records::</tt></tt>
<aname="L119"></a><ttclass="py-lineno">119</tt><ttclass="py-line"><ttclass="py-docstring"> part1, part2, ... are joined together by inserting 'middle'</tt></tt>
<aname="L120"></a><ttclass="py-lineno">120</tt><ttclass="py-line"><ttclass="py-docstring"> between them. If a part is missing, it is simply skipped.</tt></tt>
<aname="L121"></a><ttclass="py-lineno">121</tt><ttclass="py-line"><ttclass="py-docstring"> If no part is available at all, the join fails.</tt></tt>
<aname="L123"></a><ttclass="py-lineno">123</tt><ttclass="py-line"><ttclass="py-docstring"> It is possible to specify a different separator between the last</tt></tt>
<aname="L124"></a><ttclass="py-lineno">124</tt><ttclass="py-line"><ttclass="py-docstring"> two parts.</tt></tt>
</div><divid="switch-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="switch-expanded"><aname="L152"></a><ttclass="py-lineno">152</tt><ttclass="py-line"><ttclass="py-docstring">""" The switch operator helps in bringing together multiple</tt></tt>
<aname="L153"></a><ttclass="py-lineno">153</tt><ttclass="py-line"><ttclass="py-docstring"> citation parts, according to the value of a Txo.</tt></tt>
<aname="L164"></a><ttclass="py-lineno">164</tt><ttclass="py-line"><ttclass="py-comment"># Warning: we do not affect the default parameter here. Doing</tt></tt>
<aname="L165"></a><ttclass="py-lineno">165</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># so would lead to weird behavior if it is ever modified later</tt></tt>
</div><divid="switch.__call__-collapsed"style="display:none;"pad="+++"indent="++++++++"></div><divid="switch.__call__-expanded"><aname="L189"></a><ttclass="py-lineno">189</tt><ttclass="py-line"><ttclass="py-comment"># first of all, get access to the actual Txo being checked.</tt></tt>
<aname="L215"></a><ttclass="py-lineno">215</tt><ttclass="py-line"><ttclass="py-keyword">raise</tt><ttclass="py-name">TypeError</tt><ttclass="py-op">(</tt><ttclass="py-name">_</tt><ttclass="py-op">(</tt><ttclass="py-string">'%s: attribute is not a txo'</tt><ttclass="py-op">)</tt><ttclass="py-op">%</tt><ttclass="py-name">repr</tt><ttclass="py-op">(</tt><ttclass="py-name">self</tt><ttclass="py-op">)</tt><ttclass="py-op">)</tt></tt>
<aname="L231"></a><ttclass="py-lineno">231</tt><ttclass="py-line"><ttclass="py-keyword">raise</tt><ttclass="py-name">KeyError</tt><ttclass="py-op">(</tt><ttclass="py-name">_</tt><ttclass="py-op">(</tt><ttclass="py-string">'%s: unknown txo %s in group %s'</tt><ttclass="py-op">)</tt><ttclass="py-op">%</tt><ttclass="py-op">(</tt></tt>
</div><divid="_Validated-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="_Validated-expanded"><aname="L277"></a><ttclass="py-lineno">277</tt><ttclass="py-line"><ttclass="py-docstring">""" Base class for attribute accessors, providing some checks for</tt></tt>
</div><divid="_Validated.__call__-collapsed"style="display:none;"pad="+++"indent="++++++++"></div><divid="_Validated.__call__-expanded"><aname="L286"></a><ttclass="py-lineno">286</tt><ttclass="py-line"><ttclass="py-docstring">""" Return a compiled version of the attribute accessor."""</tt></tt>
<aname="L330"></a><ttclass="py-lineno">330</tt><ttclass="py-line"><ttclass="py-keyword">raise</tt><ttid="link-79"class="py-name"><atitle="Pyblio.Format.Base.Missing"class="py-name"href="#"onclick="return doclink('link-79', 'Missing', 'link-10');">Missing</a></tt><ttclass="py-op">(</tt><ttclass="py-name">_</tt><ttclass="py-op">(</tt><ttclass="py-string">'%s: no such attribute in record'</tt><ttclass="py-op">)</tt><ttclass="py-op">%</tt><ttclass="py-name">repr</tt><ttclass="py-op">(</tt><ttclass="py-name">self</tt><ttclass="py-op">)</tt><ttclass="py-op">)</tt></tt>
<aname="L339"></a><ttclass="py-lineno">339</tt><ttclass="py-line"><ttclass="py-keyword">raise</tt><ttid="link-81"class="py-name"><atitle="Pyblio.Format.Base.Missing"class="py-name"href="#"onclick="return doclink('link-81', 'Missing', 'link-10');">Missing</a></tt><ttclass="py-op">(</tt><ttclass="py-name">_</tt><ttclass="py-op">(</tt><ttclass="py-string">'%s: no such attribute in record'</tt><ttclass="py-op">)</tt><ttclass="py-op">%</tt><ttclass="py-name">repr</tt><ttclass="py-op">(</tt><ttclass="py-name">self</tt><ttclass="py-op">)</tt><ttclass="py-op">)</tt></tt>
<aname="L354"></a><ttclass="py-lineno">354</tt><ttclass="py-line"><ttclass="py-keyword">raise</tt><ttid="link-84"class="py-name"><atitle="Pyblio.Format.Base.Missing"class="py-name"href="#"onclick="return doclink('link-84', 'Missing', 'link-10');">Missing</a></tt><ttclass="py-op">(</tt><ttclass="py-name">_</tt><ttclass="py-op">(</tt><ttclass="py-string">'%s: no such attribute in record'</tt><ttclass="py-op">)</tt><ttclass="py-op">%</tt><ttclass="py-name">repr</tt><ttclass="py-op">(</tt><ttclass="py-name">self</tt><ttclass="py-op">)</tt><ttclass="py-op">)</tt></tt>
<aname="L363"></a><ttclass="py-lineno">363</tt><ttclass="py-line"><ttclass="py-keyword">raise</tt><ttid="link-86"class="py-name"><atitle="Pyblio.Format.Base.Missing"class="py-name"href="#"onclick="return doclink('link-86', 'Missing', 'link-10');">Missing</a></tt><ttclass="py-op">(</tt><ttclass="py-name">_</tt><ttclass="py-op">(</tt><ttclass="py-string">'%s: no such attribute in record'</tt><ttclass="py-op">)</tt><ttclass="py-op">%</tt><ttclass="py-name">repr</tt><ttclass="py-op">(</tt><ttclass="py-name">self</tt><ttclass="py-op">)</tt><ttclass="py-op">)</tt></tt>
</div><divid="_SynTag-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="_SynTag-expanded"><aname="L381"></a><ttclass="py-lineno">381</tt><ttclass="py-line"><ttclass="py-docstring">""" This is a layout tag before its [] marker. """</tt></tt>
</div><divid="_SynTag.__call__-collapsed"style="display:none;"pad="+++"indent="++++++++"></div><divid="_SynTag.__call__-expanded"><aname="L388"></a><ttclass="py-lineno">388</tt><ttclass="py-line"><ttclass="py-docstring">"""Change attributes of this tag. This is implemented using</tt></tt>
<aname="L389"></a><ttclass="py-lineno">389</tt><ttclass="py-line"><ttclass="py-docstring"> __call__ because it then allows the natural syntax::</tt></tt>
<aname="L421"></a><ttclass="py-lineno">421</tt><ttclass="py-line"><ttclass="py-docstring">""" This is a layout tag after its [] marker, but before the</tt></tt>
</div><divid="_Proto-collapsed"style="display:none;"pad="+++"indent="++++"></div><divid="_Proto-expanded"><aname="L459"></a><ttclass="py-lineno">459</tt><ttclass="py-line"><ttclass="py-docstring">"""Proto is a string subclass. Instances of Proto, which are constructed</tt></tt>
<aname="L460"></a><ttclass="py-lineno">460</tt><ttclass="py-line"><ttclass="py-docstring"> with a string, will construct Tag instances in response to __call__</tt></tt>
<aname="L461"></a><ttclass="py-lineno">461</tt><ttclass="py-line"><ttclass="py-docstring"> and __getitem__, delegating responsibility to the tag.</tt></tt>
<aname="L481"></a><ttclass="py-lineno">481</tt><ttclass="py-line"><ttclass="py-comment"></tt><ttclass="py-comment"># Helper for building simple additional DSL functions</tt></tt>
<aname="L487"></a><ttclass="py-lineno">487</tt><ttclass="py-line"><ttclass="py-docstring">""" Transform a simple function into a lazy function lifted in the</tt></tt>
<aname="L490"></a><ttclass="py-lineno">490</tt><ttclass="py-line"><ttclass="py-docstring"> This is only sugar : the initial function must be aware that every</tt></tt>
<aname="L491"></a><ttclass="py-lineno">491</tt><ttclass="py-line"><ttclass="py-docstring"> argument must be made strict by calling them before use.</tt></tt>