[ SEA-GHOST MINI SHELL]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Helpers for versioning software — kitchen 1.1.1 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '1.1.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within kitchen 1.1.1 documentation"
href="_static/opensearch.xml"/>
<link rel="top" title="kitchen 1.1.1 documentation" href="index.html" />
<link rel="up" title="Kitchen API" href="api-overview.html" />
<link rel="next" title="Python 2.4 Compatibiity" href="api-pycompat24.html" />
<link rel="prev" title="Kitchen.iterutils Module" href="api-iterutils.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="api-pycompat24.html" title="Python 2.4 Compatibiity"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="api-iterutils.html" title="Kitchen.iterutils Module"
accesskey="P">previous</a> |</li>
<li><a href="index.html">kitchen 1.1.1 documentation</a> »</li>
<li><a href="api-overview.html" accesskey="U">Kitchen API</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-kitchen.versioning">
<span id="helpers-for-versioning-software"></span><h1>Helpers for versioning software<a class="headerlink" href="#module-kitchen.versioning" title="Permalink to this headline">¶</a></h1>
<div class="section" id="pep-386-compliant-versioning">
<h2>PEP-386 compliant versioning<a class="headerlink" href="#pep-386-compliant-versioning" title="Permalink to this headline">¶</a></h2>
<p><span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> defines a standard format for version strings. This module
contains a function for creating strings in that format.</p>
<dl class="function">
<dt id="kitchen.versioning.version_tuple_to_string">
<tt class="descclassname">kitchen.versioning.</tt><tt class="descname">version_tuple_to_string</tt><big>(</big><em>version_info</em><big>)</big><a class="headerlink" href="#kitchen.versioning.version_tuple_to_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <span class="target" id="index-1"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> version string from a <span class="target" id="index-2"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> style version tuple</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>version_info</strong> – Nested set of tuples that describes the version. See
below for an example.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a version string</td>
</tr>
</tbody>
</table>
<p>This function implements just enough of <span class="target" id="index-3"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> to satisfy our needs.
<span class="target" id="index-4"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> defines a standard format for version strings and refers to
a function that will be merged into the <a class="reference external" href="http://docs.python.org/library">python standard library</a> that transforms a tuple
of version information into a standard version string. This function is
an implementation of that function. Once that function becomes available
in the <a class="reference external" href="http://docs.python.org/library">python standard library</a> we will start using it and deprecate this function.</p>
<p><tt class="xref py py-attr docutils literal"><span class="pre">version_info</span></tt> takes the form that <span class="target" id="index-5"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a>‘s
<tt class="xref py py-func docutils literal"><span class="pre">NormalizedVersion.from_parts()</span></tt> uses:</p>
<div class="highlight-python"><pre>((Major, Minor, [Micros]), [(Alpha/Beta/rc marker, version)],
[(post/dev marker, version)])
Ex: ((1, 0, 0), ('a', 2), ('dev', 3456))</pre>
</div>
<p>It generates a <span class="target" id="index-6"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> compliant version string:</p>
<div class="highlight-python"><pre>N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN]
Ex: 1.0.0a2.dev3456</pre>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This function does next to no error checking. It’s up to the
person defining the version tuple to make sure that the values make
sense. If the <span class="target" id="index-7"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0386"><strong>PEP 386</strong></a> compliant version parser doesn’t get
released soon we’ll look at making this function check that the
version tuple makes sense before transforming it into a string.</p>
</div>
<p>It’s recommended that you use this function to keep
a <tt class="xref py py-data docutils literal"><span class="pre">__version_info__</span></tt> tuple and <tt class="xref py py-data docutils literal"><span class="pre">__version__</span></tt> string in your
modules. Why do we need both a tuple and a string? The string is often
useful for putting into human readable locations like release
announcements, version strings in tarballs, etc. Meanwhile the tuple is
very easy for a computer to compare. For example, kitchen sets up its
version information like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">kitchen.versioning</span> <span class="kn">import</span> <span class="n">version_tuple_to_string</span>
<span class="n">__version_info__</span> <span class="o">=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">),)</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="n">version_tuple_to_string</span><span class="p">(</span><span class="n">__version_info__</span><span class="p">)</span>
</pre></div>
</div>
<p>Other programs that depend on a kitchen version between 0.2.1 and 0.3.0
can find whether the present version is okay with code like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">kitchen</span> <span class="kn">import</span> <span class="n">__version_info__</span><span class="p">,</span> <span class="n">__version__</span>
<span class="k">if</span> <span class="n">__version_info__</span> <span class="o"><</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">1</span><span class="p">),)</span> <span class="ow">or</span> <span class="n">__version_info__</span> <span class="o">>=</span> <span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">0</span><span class="p">),):</span>
<span class="k">print</span> <span class="s">'kitchen is present but not at the right version.'</span>
<span class="k">print</span> <span class="s">'We need at least version 0.2.1 and less than 0.3.0'</span>
<span class="k">print</span> <span class="s">'Currently found: kitchen-</span><span class="si">%s</span><span class="s">'</span> <span class="o">%</span> <span class="n">__version__</span>
</pre></div>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Helpers for versioning software</a><ul>
<li><a class="reference internal" href="#pep-386-compliant-versioning">PEP-386 compliant versioning</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="api-iterutils.html"
title="previous chapter">Kitchen.iterutils Module</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="api-pycompat24.html"
title="next chapter">Python 2.4 Compatibiity</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/api-versioning.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="api-pycompat24.html" title="Python 2.4 Compatibiity"
>next</a> |</li>
<li class="right" >
<a href="api-iterutils.html" title="Kitchen.iterutils Module"
>previous</a> |</li>
<li><a href="index.html">kitchen 1.1.1 documentation</a> »</li>
<li><a href="api-overview.html" >Kitchen API</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2011 Red Hat, Inc. and others.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>
SEA-GHOST - SHELL CODING BY SEA-GHOST