Current File : //usr/share/doc/python-babel-0.9.6/doc/api/babel.util-module.html |
<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>babel.util</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="babel-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
<a href="babel-module.html">Package babel</a> ::
Module util
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
</table>
</td>
</tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module util</h1><p class="nomargin-top"></p>
Various utility classes and functions.
<!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Classes</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="babel.util.odict-class.html" class="summary-name">odict</a><br />
Ordered dict implementation.
</td>
</tr>
</table>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Functions</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"><tt class="rst-docutils literal">iterator</tt></span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="babel.util-module.html#distinct" class="summary-sig-name">distinct</a>(<span class="summary-sig-arg">iterable</span>)</span><br />
Yield all items in an iterable collection that are distinct.</td>
<td align="right" valign="top">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"><code class="link">bool</code></span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="babel.util-module.html#pathmatch" class="summary-sig-name">pathmatch</a>(<span class="summary-sig-arg">pattern</span>,
<span class="summary-sig-arg">filename</span>)</span><br />
Extended pathname pattern matching.</td>
<td align="right" valign="top">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"><code class="link">list</code></span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="babel.util-module.html#wraptext" class="summary-sig-name">wraptext</a>(<span class="summary-sig-arg">text</span>,
<span class="summary-sig-arg">width</span>=<span class="summary-sig-default">70</span>,
<span class="summary-sig-arg">initial_indent</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>,
<span class="summary-sig-arg">subsequent_indent</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>)</span><br />
Simple wrapper around the <tt class="rst-docutils literal">textwrap.wrap</tt> function in the standard
library.</td>
<td align="right" valign="top">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="relpath"></a><span class="summary-sig-name">relpath</span>(<span class="summary-sig-arg">path</span>,
<span class="summary-sig-arg">start</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">.</code><code class="variable-quote">'</code></span>)</span><br />
Return a relative version of a path</td>
<td align="right" valign="top">
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Variables</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">tzinfo</span>
</td><td class="summary">
<a name="UTC"></a><span class="summary-name">UTC</span> = <code title="<UTC>"><UTC></code><br />
tzinfo object for UTC (Universal Time).
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type">tzinfo</span>
</td><td class="summary">
<a name="LOCALTZ"></a><span class="summary-name">LOCALTZ</span> = <code title="LocalTimezone()">LocalTimezone()</code><br />
tzinfo object for local time-zone.
</td>
</tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Function Details</span></td>
</tr>
</table>
<a name="distinct"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">distinct</span>(<span class="sig-arg">iterable</span>)</span>
</h3>
</td><td align="right" valign="top"
>
</td>
</tr></table>
<p>Yield all items in an iterable collection that are distinct.</p>
<p>Unlike when using sets for a similar effect, the original ordering of the
items in the collection is preserved by this function.</p>
<pre class="py-doctest">
<span class="py-prompt">>>> </span><span class="py-keyword">print</span> list(distinct([1, 2, 1, 3, 4, 4]))
<span class="py-output">[1, 2, 3, 4]</span>
<span class="py-output"></span><span class="py-prompt">>>> </span><span class="py-keyword">print</span> list(distinct(<span class="py-string">'foobar'</span>))
<span class="py-output">['f', 'o', 'b', 'a', 'r']</span></pre>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>iterable</code></strong> - the iterable collection providing the data</li>
</ul></dd>
<dt>Returns: <tt class="rst-rst-docutils literal rst-docutils literal">iterator</tt></dt>
<dd>the distinct items in the collection</dd>
</dl>
</td></tr></table>
</div>
<a name="pathmatch"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">pathmatch</span>(<span class="sig-arg">pattern</span>,
<span class="sig-arg">filename</span>)</span>
</h3>
</td><td align="right" valign="top"
>
</td>
</tr></table>
<p>Extended pathname pattern matching.</p>
<p>This function is similar to what is provided by the <tt class="rst-docutils literal">fnmatch</tt> module in
the Python standard library, but:</p>
<blockquote>
<ul class="rst-simple">
<li>can match complete (relative or absolute) path names, and not just file
names, and</li>
<li>also supports a convenience pattern ("**") to match files at any
directory level.</li>
</ul>
</blockquote>
<p>Examples:</p>
<pre class="py-doctest">
<span class="py-prompt">>>> </span>pathmatch(<span class="py-string">'**.py'</span>, <span class="py-string">'bar.py'</span>)
<span class="py-output">True</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>pathmatch(<span class="py-string">'**.py'</span>, <span class="py-string">'foo/bar/baz.py'</span>)
<span class="py-output">True</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>pathmatch(<span class="py-string">'**.py'</span>, <span class="py-string">'templates/index.html'</span>)
<span class="py-output">False</span></pre>
<pre class="py-doctest">
<span class="py-prompt">>>> </span>pathmatch(<span class="py-string">'**/templates/*.html'</span>, <span class="py-string">'templates/index.html'</span>)
<span class="py-output">True</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>pathmatch(<span class="py-string">'**/templates/*.html'</span>, <span class="py-string">'templates/foo/bar.html'</span>)
<span class="py-output">False</span></pre>
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>pattern</code></strong> - the glob pattern</li>
<li><strong class="pname"><code>filename</code></strong> - the path name of the file to match against</li>
</ul></dd>
<dt>Returns: <code class="link">bool</code></dt>
<dd><code class="link">True</code> if the path name matches the pattern, <code class="link">False</code> otherwise</dd>
</dl>
</td></tr></table>
</div>
<a name="wraptext"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">wraptext</span>(<span class="sig-arg">text</span>,
<span class="sig-arg">width</span>=<span class="sig-default">70</span>,
<span class="sig-arg">initial_indent</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>,
<span class="sig-arg">subsequent_indent</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string"></code><code class="variable-quote">'</code></span>)</span>
</h3>
</td><td align="right" valign="top"
>
</td>
</tr></table>
Simple wrapper around the <tt class="rst-rst-docutils literal rst-docutils literal">textwrap.wrap</tt> function in the standard
library. This version does not wrap lines on hyphens in words.
<dl class="fields">
<dt>Parameters:</dt>
<dd><ul class="nomargin-top">
<li><strong class="pname"><code>text</code></strong> - the text to wrap</li>
<li><strong class="pname"><code>width</code></strong> - the maximum line width</li>
<li><strong class="pname"><code>initial_indent</code></strong> - string that will be prepended to the first line of
wrapped output</li>
<li><strong class="pname"><code>subsequent_indent</code></strong> - string that will be prepended to all lines save
the first of wrapped output</li>
</ul></dd>
<dt>Returns: <code class="link">list</code></dt>
<dd>a list of lines</dd>
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="babel-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
><a class="navbar" target="_top" href="../index.html">Documentation Index</a></th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1 on Thu Mar 17 15:12:44 2011
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>