Output changed slightly in pygments 2.5.
I thought it was easier to copy the line and add a version
check than to add a regular expression because the line has some
special characters. I also like tests explicitly calling out where
they vary.
Output changed slightly in pygments 2.5.
I thought it was easier to copy the line and add a version
check than to add a regular expression because the line has some
special characters. I also like tests explicitly calling out where
they vary.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
import pygments | import pygments | ||||
pygments.highlight # silence unused import warning | pygments.highlight # silence unused import warning | ||||
return True | return True | ||||
except ImportError: | except ImportError: | ||||
return False | return False | ||||
@check("pygments25", "Pygments version >= 2.5") | |||||
def pygments25(): | |||||
try: | |||||
import pygments | |||||
v = pygments.__version__ | |||||
except ImportError: | |||||
return False | |||||
parts = v.split(".") | |||||
major = int(parts[0]) | |||||
minor = int(parts[1]) | |||||
return (major, minor) >= (2, 5) | |||||
@check("outer-repo", "outer repo") | @check("outer-repo", "outer repo") | ||||
def has_outer_repo(): | def has_outer_repo(): | ||||
# failing for other reasons than 'no repo' imply that there is a repo | # failing for other reasons than 'no repo' imply that there is a repo | ||||
return not matchoutput('hg root 2>&1', br'abort: no repository found', True) | return not matchoutput('hg root 2>&1', br'abort: no repository found', True) | ||||
@check("ssl", "ssl module available") | @check("ssl", "ssl module available") | ||||
def has_ssl(): | def has_ssl(): |
<span id="l23"></span><a href="#l23"></a> | <span id="l23"></span><a href="#l23"></a> | ||||
<span id="l24"><span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span></span><a href="#l24"></a> | <span id="l24"><span class="kn">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span></span><a href="#l24"></a> | ||||
<span id="l25"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l25"></a> | <span id="l25"> <span class="kn">import</span> <span class="nn">sys</span></span><a href="#l25"></a> | ||||
<span id="l26"> <span class="kn">try</span><span class="p">:</span></span><a href="#l26"></a> | <span id="l26"> <span class="kn">try</span><span class="p">:</span></span><a href="#l26"></a> | ||||
<span id="l27"> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></span><a href="#l27"></a> | <span id="l27"> <span class="n">n</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></span><a href="#l27"></a> | ||||
<span id="l28"> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></span><a href="#l28"></a> | <span id="l28"> <span class="kn">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">IndexError</span><span class="p">):</span></span><a href="#l28"></a> | ||||
<span id="l29"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l29"></a> | <span id="l29"> <span class="n">n</span> <span class="o">=</span> <span class="mi">10</span></span><a href="#l29"></a> | ||||
<span id="l30"> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></span><a href="#l30"></a> | <span id="l30"> <span class="n">p</span> <span class="o">=</span> <span class="n">primes</span><span class="p">()</span></span><a href="#l30"></a> | ||||
<span id="l31"> <span class="kn">print</span><span class="p">(</span><span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">))))</span></span><a href="#l31"></a> | <span id="l31"> <span class="nb">print</span><span class="p">(</span><span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">))))</span></span><a href="#l31"></a> (pygments25 !) | ||||
<span id="l31"> <span class="kn">print</span><span class="p">(</span><span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">))))</span></span><a href="#l31"></a> (no-pygments25 !) | |||||
<span id="l32"></span><a href="#l32"></a> | <span id="l32"></span><a href="#l32"></a> | ||||
</pre> | </pre> | ||||
</div> | </div> | ||||
<script type="text/javascript" src="/static/followlines.js"></script> | <script type="text/javascript" src="/static/followlines.js"></script> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
a | a | ||||
</div> | </div> | ||||
<div><em>test</em></div> | <div><em>test</em></div> | ||||
<div>parents: </div> | <div>parents: </div> | ||||
<a href="/diff/687f2d169546/primes.py">diff</a> | <a href="/diff/687f2d169546/primes.py">diff</a> | ||||
<a href="/rev/687f2d169546">changeset</a> | <a href="/rev/687f2d169546">changeset</a> | ||||
</div> | </div> | ||||
</td> | </td> | ||||
<td class="source followlines-btn-parent"><a href="#l31"> 31</a> <span class="kn">print</span><span class="p">(</span><span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">))))</span></td> | <td class="source followlines-btn-parent"><a href="#l31"> 31</a> <span class="nb">print</span><span class="p">(</span><span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">))))</span></td> (pygments25 !) | ||||
<td class="source followlines-btn-parent"><a href="#l31"> 31</a> <span class="kn">print</span><span class="p">(</span><span class="s">"The first </span><span class="si">%d</span><span class="s"> primes: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="nb">list</span><span class="p">(</span><span class="n">itertools</span><span class="o">.</span><span class="n">islice</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">n</span><span class="p">))))</span></td> (no-pygments25 !) | |||||
</tr> | </tr> | ||||
<tr id="l32" class="thisrev"> | <tr id="l32" class="thisrev"> | ||||
<td class="annotate parity0"> | <td class="annotate parity0"> | ||||
<div class="annotate-info"> | <div class="annotate-info"> | ||||
<div> | <div> | ||||
<a href="/annotate/687f2d169546/primes.py#l32"> | <a href="/annotate/687f2d169546/primes.py#l32"> | ||||
687f2d169546</a> | 687f2d169546</a> |