1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
|
<?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><br /><br />
Various utility classes and functions.<br /><br />
<!-- ==================== 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"><span class="pre">iterator</span></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">basestring</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#relpath" class="summary-sig-name">relpath</a>(<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 />
Compute the relative path to one path from another.</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>
</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"><span class="pre">iterator</span></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>
</table>
<p>Extended pathname pattern matching.</p>
<p>This function is similar to what is provided by the <tt class="rst-docutils literal"><span class="pre">fnmatch</span></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="relpath"></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">relpath</span>(<span class="sig-arg">path</span>,
<span class="sig-arg">start</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>
</table>
<p>Compute the relative path to one path from another.</p>
<pre class="py-doctest">
<span class="py-prompt">>>> </span>relpath(<span class="py-string">'foo/bar.txt'</span>, <span class="py-string">''</span>).replace(os.sep, <span class="py-string">'/'</span>)
<span class="py-output">'foo/bar.txt'</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>relpath(<span class="py-string">'foo/bar.txt'</span>, <span class="py-string">'foo'</span>).replace(os.sep, <span class="py-string">'/'</span>)
<span class="py-output">'bar.txt'</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>relpath(<span class="py-string">'foo/bar.txt'</span>, <span class="py-string">'baz'</span>).replace(os.sep, <span class="py-string">'/'</span>)
<span class="py-output">'../foo/bar.txt'</span></pre>
<dl class="fields">
<dt>Returns: <code class="link">basestring</code></dt>
<dd>the relative path</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.0beta1 on Fri Sep 7 12:36:49 2007
</td>
<td align="right" class="footer">
<a 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>
|