admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | <?xml version="1.0" encoding="ascii"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | "DTD/xhtml1-transitional.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 5 | <head> |
| 6 | <title>TestON.core.ast</title> |
| 7 | <link rel="stylesheet" href="epydoc.css" type="text/css" /> |
| 8 | <script type="text/javascript" src="epydoc.js"></script> |
| 9 | </head> |
| 10 | |
| 11 | <body bgcolor="white" text="black" link="blue" vlink="#204080" |
| 12 | alink="#204080"> |
| 13 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 14 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 15 | bgcolor="#a0c0ff" cellspacing="0"> |
| 16 | <tr valign="middle"> |
| 17 | <!-- Home link --> |
| 18 | <th> <a |
| 19 | href="TestON-module.html">Home</a> </th> |
| 20 | |
| 21 | <!-- Tree link --> |
| 22 | <th> <a |
| 23 | href="module-tree.html">Trees</a> </th> |
| 24 | |
| 25 | <!-- Index link --> |
| 26 | <th> <a |
| 27 | href="identifier-index.html">Indices</a> </th> |
| 28 | |
| 29 | <!-- Help link --> |
| 30 | <th> <a |
| 31 | href="help.html">Help</a> </th> |
| 32 | |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 33 | <!-- Project homepage --> |
| 34 | <th class="navbar" align="right" width="100%"> |
| 35 | <table border="0" cellpadding="0" cellspacing="0"> |
| 36 | <tr><th class="navbar" align="center" |
| 37 | >TestON</th> |
| 38 | </tr></table></th> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 39 | </tr> |
| 40 | </table> |
| 41 | <table width="100%" cellpadding="0" cellspacing="0"> |
| 42 | <tr valign="top"> |
| 43 | <td width="100%"> |
| 44 | <span class="breadcrumbs"> |
| 45 | <a href="TestON-module.html">Package TestON</a> :: |
| 46 | <a href="TestON.core-module.html">Package core</a> :: |
| 47 | Module ast |
| 48 | </span> |
| 49 | </td> |
| 50 | <td> |
| 51 | <table cellpadding="0" cellspacing="0"> |
| 52 | <!-- hide/show private --> |
| 53 | <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" |
| 54 | onclick="toggle_private();">hide private</a>]</span></td></tr> |
| 55 | <tr><td align="right"><span class="options" |
| 56 | >[<a href="frames.html" target="_top">frames</a |
| 57 | >] | <a href="TestON.core.ast-module.html" |
| 58 | target="_top">no frames</a>]</span></td></tr> |
| 59 | </table> |
| 60 | </td> |
| 61 | </tr> |
| 62 | </table> |
| 63 | <!-- ==================== MODULE DESCRIPTION ==================== --> |
| 64 | <h1 class="epydoc">Module ast</h1><p class="nomargin-top"><span class="codelink"><a href="TestON.core.ast-pysrc.html">source code</a></span></p> |
| 65 | <pre class="literalblock"> |
| 66 | |
| 67 | ast |
| 68 | ~~~ |
| 69 | |
| 70 | The `ast` module helps Python applications to process trees of the Python |
| 71 | abstract syntax grammar. The abstract syntax itself might change with |
| 72 | each Python release; this module helps to find out programmatically what |
| 73 | the current grammar looks like and allows modifications of it. |
| 74 | |
| 75 | An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as |
| 76 | a flag to the `compile()` builtin function or by using the `parse()` |
| 77 | function from this module. The result will be a tree of objects whose |
| 78 | classes all inherit from `ast.AST`. |
| 79 | |
| 80 | A modified abstract syntax tree can be compiled into a Python code object |
| 81 | using the built-in `compile()` function. |
| 82 | |
| 83 | Additionally various helper functions are provided that make working with |
| 84 | the trees simpler. The main intention of the helper functions and this |
| 85 | module in general is to provide an easy to use interface for libraries |
| 86 | that work tightly with the python syntax (template engines for example). |
| 87 | |
| 88 | |
| 89 | :copyright: Copyright 2008 by Armin Ronacher. |
| 90 | :license: Python License. |
| 91 | |
| 92 | </pre> |
| 93 | |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 94 | <hr /> |
| 95 | <div class="fields"> <p><strong>Version:</strong> |
| 96 | 82160 |
| 97 | </p> |
| 98 | </div><!-- ==================== CLASSES ==================== --> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 99 | <a name="section-Classes"></a> |
| 100 | <table class="summary" border="1" cellpadding="3" |
| 101 | cellspacing="0" width="100%" bgcolor="white"> |
| 102 | <tr bgcolor="#70b0f0" class="table-header"> |
| 103 | <td colspan="2" class="table-header"> |
| 104 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 105 | <tr valign="top"> |
| 106 | <td align="left"><span class="table-header">Classes</span></td> |
| 107 | <td align="right" valign="top" |
| 108 | ><span class="options">[<a href="#section-Classes" |
| 109 | class="privatelink" onclick="toggle_private();" |
| 110 | >hide private</a>]</span></td> |
| 111 | </tr> |
| 112 | </table> |
| 113 | </td> |
| 114 | </tr> |
| 115 | <tr> |
| 116 | <td width="15%" align="right" valign="top" class="summary"> |
| 117 | <span class="summary-type"> </span> |
| 118 | </td><td class="summary"> |
| 119 | <a href="TestON.core.ast.NodeVisitor-class.html" class="summary-name">NodeVisitor</a><br /> |
| 120 | A node visitor base class that walks the abstract syntax tree and |
| 121 | calls a visitor function for every node found. |
| 122 | </td> |
| 123 | </tr> |
| 124 | <tr> |
| 125 | <td width="15%" align="right" valign="top" class="summary"> |
| 126 | <span class="summary-type"> </span> |
| 127 | </td><td class="summary"> |
| 128 | <a href="TestON.core.ast.NodeTransformer-class.html" class="summary-name">NodeTransformer</a><br /> |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 129 | A :class:`NodeVisitor` subclass that walks the abstract syntax tree |
| 130 | and allows modification of nodes. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 131 | </td> |
| 132 | </tr> |
| 133 | </table> |
| 134 | <!-- ==================== FUNCTIONS ==================== --> |
| 135 | <a name="section-Functions"></a> |
| 136 | <table class="summary" border="1" cellpadding="3" |
| 137 | cellspacing="0" width="100%" bgcolor="white"> |
| 138 | <tr bgcolor="#70b0f0" class="table-header"> |
| 139 | <td colspan="2" class="table-header"> |
| 140 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 141 | <tr valign="top"> |
| 142 | <td align="left"><span class="table-header">Functions</span></td> |
| 143 | <td align="right" valign="top" |
| 144 | ><span class="options">[<a href="#section-Functions" |
| 145 | class="privatelink" onclick="toggle_private();" |
| 146 | >hide private</a>]</span></td> |
| 147 | </tr> |
| 148 | </table> |
| 149 | </td> |
| 150 | </tr> |
| 151 | <tr> |
| 152 | <td width="15%" align="right" valign="top" class="summary"> |
| 153 | <span class="summary-type"> </span> |
| 154 | </td><td class="summary"> |
| 155 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 156 | <tr> |
| 157 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#parse" class="summary-sig-name">parse</a>(<span class="summary-sig-arg">source</span>, |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 158 | <span class="summary-sig-arg">filename</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string"><unknown></code><code class="variable-quote">'</code></span>, |
| 159 | <span class="summary-sig-arg">mode</span>=<span class="summary-sig-default"><code class="variable-quote">'</code><code class="variable-string">exec</code><code class="variable-quote">'</code></span>)</span><br /> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 160 | Parse the source into an AST node.</td> |
| 161 | <td align="right" valign="top"> |
| 162 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#parse">source code</a></span> |
| 163 | |
| 164 | </td> |
| 165 | </tr> |
| 166 | </table> |
| 167 | |
| 168 | </td> |
| 169 | </tr> |
| 170 | <tr> |
| 171 | <td width="15%" align="right" valign="top" class="summary"> |
| 172 | <span class="summary-type"> </span> |
| 173 | </td><td class="summary"> |
| 174 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 175 | <tr> |
| 176 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#literal_eval" class="summary-sig-name">literal_eval</a>(<span class="summary-sig-arg">node_or_string</span>)</span><br /> |
| 177 | Safely evaluate an expression node or a string containing a Python |
| 178 | expression.</td> |
| 179 | <td align="right" valign="top"> |
| 180 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#literal_eval">source code</a></span> |
| 181 | |
| 182 | </td> |
| 183 | </tr> |
| 184 | </table> |
| 185 | |
| 186 | </td> |
| 187 | </tr> |
| 188 | <tr> |
| 189 | <td width="15%" align="right" valign="top" class="summary"> |
| 190 | <span class="summary-type"> </span> |
| 191 | </td><td class="summary"> |
| 192 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 193 | <tr> |
| 194 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#dump" class="summary-sig-name">dump</a>(<span class="summary-sig-arg">node</span>, |
| 195 | <span class="summary-sig-arg">annotate_fields</span>=<span class="summary-sig-default">True</span>, |
| 196 | <span class="summary-sig-arg">include_attributes</span>=<span class="summary-sig-default">False</span>)</span><br /> |
| 197 | Return a formatted dump of the tree in *node*.</td> |
| 198 | <td align="right" valign="top"> |
| 199 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#dump">source code</a></span> |
| 200 | |
| 201 | </td> |
| 202 | </tr> |
| 203 | </table> |
| 204 | |
| 205 | </td> |
| 206 | </tr> |
| 207 | <tr> |
| 208 | <td width="15%" align="right" valign="top" class="summary"> |
| 209 | <span class="summary-type"> </span> |
| 210 | </td><td class="summary"> |
| 211 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 212 | <tr> |
| 213 | <td><span class="summary-sig"><a name="copy_location"></a><span class="summary-sig-name">copy_location</span>(<span class="summary-sig-arg">new_node</span>, |
| 214 | <span class="summary-sig-arg">old_node</span>)</span><br /> |
| 215 | Copy source location (`lineno` and `col_offset` attributes) from |
| 216 | *old_node* to *new_node* if possible, and return *new_node*.</td> |
| 217 | <td align="right" valign="top"> |
| 218 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#copy_location">source code</a></span> |
| 219 | |
| 220 | </td> |
| 221 | </tr> |
| 222 | </table> |
| 223 | |
| 224 | </td> |
| 225 | </tr> |
| 226 | <tr> |
| 227 | <td width="15%" align="right" valign="top" class="summary"> |
| 228 | <span class="summary-type"> </span> |
| 229 | </td><td class="summary"> |
| 230 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 231 | <tr> |
| 232 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#fix_missing_locations" class="summary-sig-name">fix_missing_locations</a>(<span class="summary-sig-arg">node</span>)</span><br /> |
| 233 | When you compile a node tree with compile(), the compiler expects |
| 234 | lineno and col_offset attributes for every node that supports them.</td> |
| 235 | <td align="right" valign="top"> |
| 236 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#fix_missing_locations">source code</a></span> |
| 237 | |
| 238 | </td> |
| 239 | </tr> |
| 240 | </table> |
| 241 | |
| 242 | </td> |
| 243 | </tr> |
| 244 | <tr> |
| 245 | <td width="15%" align="right" valign="top" class="summary"> |
| 246 | <span class="summary-type"> </span> |
| 247 | </td><td class="summary"> |
| 248 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 249 | <tr> |
| 250 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#increment_lineno" class="summary-sig-name">increment_lineno</a>(<span class="summary-sig-arg">node</span>, |
| 251 | <span class="summary-sig-arg">n</span>=<span class="summary-sig-default">1</span>)</span><br /> |
| 252 | Increment the line number of each node in the tree starting at *node* |
| 253 | by *n*.</td> |
| 254 | <td align="right" valign="top"> |
| 255 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#increment_lineno">source code</a></span> |
| 256 | |
| 257 | </td> |
| 258 | </tr> |
| 259 | </table> |
| 260 | |
| 261 | </td> |
| 262 | </tr> |
| 263 | <tr> |
| 264 | <td width="15%" align="right" valign="top" class="summary"> |
| 265 | <span class="summary-type"> </span> |
| 266 | </td><td class="summary"> |
| 267 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 268 | <tr> |
| 269 | <td><span class="summary-sig"><a name="iter_fields"></a><span class="summary-sig-name">iter_fields</span>(<span class="summary-sig-arg">node</span>)</span><br /> |
| 270 | Yield a tuple of ``(fieldname, value)`` for each field in |
| 271 | ``node._fields`` that is present on *node*.</td> |
| 272 | <td align="right" valign="top"> |
| 273 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#iter_fields">source code</a></span> |
| 274 | |
| 275 | </td> |
| 276 | </tr> |
| 277 | </table> |
| 278 | |
| 279 | </td> |
| 280 | </tr> |
| 281 | <tr> |
| 282 | <td width="15%" align="right" valign="top" class="summary"> |
| 283 | <span class="summary-type"> </span> |
| 284 | </td><td class="summary"> |
| 285 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 286 | <tr> |
| 287 | <td><span class="summary-sig"><a name="iter_child_nodes"></a><span class="summary-sig-name">iter_child_nodes</span>(<span class="summary-sig-arg">node</span>)</span><br /> |
| 288 | Yield all direct child nodes of *node*, that is, all fields that are |
| 289 | nodes and all items of fields that are lists of nodes.</td> |
| 290 | <td align="right" valign="top"> |
| 291 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#iter_child_nodes">source code</a></span> |
| 292 | |
| 293 | </td> |
| 294 | </tr> |
| 295 | </table> |
| 296 | |
| 297 | </td> |
| 298 | </tr> |
| 299 | <tr> |
| 300 | <td width="15%" align="right" valign="top" class="summary"> |
| 301 | <span class="summary-type"> </span> |
| 302 | </td><td class="summary"> |
| 303 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 304 | <tr> |
| 305 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#get_docstring" class="summary-sig-name">get_docstring</a>(<span class="summary-sig-arg">node</span>, |
| 306 | <span class="summary-sig-arg">clean</span>=<span class="summary-sig-default">True</span>)</span><br /> |
| 307 | Return the docstring for the given node or None if no docstring can |
| 308 | be found.</td> |
| 309 | <td align="right" valign="top"> |
| 310 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#get_docstring">source code</a></span> |
| 311 | |
| 312 | </td> |
| 313 | </tr> |
| 314 | </table> |
| 315 | |
| 316 | </td> |
| 317 | </tr> |
| 318 | <tr> |
| 319 | <td width="15%" align="right" valign="top" class="summary"> |
| 320 | <span class="summary-type"> </span> |
| 321 | </td><td class="summary"> |
| 322 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 323 | <tr> |
| 324 | <td><span class="summary-sig"><a href="TestON.core.ast-module.html#walk" class="summary-sig-name">walk</a>(<span class="summary-sig-arg">node</span>)</span><br /> |
| 325 | Recursively yield all descendant nodes in the tree starting at *node* |
| 326 | (including *node* itself), in no specified order.</td> |
| 327 | <td align="right" valign="top"> |
| 328 | <span class="codelink"><a href="TestON.core.ast-pysrc.html#walk">source code</a></span> |
| 329 | |
| 330 | </td> |
| 331 | </tr> |
| 332 | </table> |
| 333 | |
| 334 | </td> |
| 335 | </tr> |
| 336 | </table> |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 337 | <!-- ==================== VARIABLES ==================== --> |
| 338 | <a name="section-Variables"></a> |
| 339 | <table class="summary" border="1" cellpadding="3" |
| 340 | cellspacing="0" width="100%" bgcolor="white"> |
| 341 | <tr bgcolor="#70b0f0" class="table-header"> |
| 342 | <td colspan="2" class="table-header"> |
| 343 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 344 | <tr valign="top"> |
| 345 | <td align="left"><span class="table-header">Variables</span></td> |
| 346 | <td align="right" valign="top" |
| 347 | ><span class="options">[<a href="#section-Variables" |
| 348 | class="privatelink" onclick="toggle_private();" |
| 349 | >hide private</a>]</span></td> |
| 350 | </tr> |
| 351 | </table> |
| 352 | </td> |
| 353 | </tr> |
| 354 | <tr> |
| 355 | <td width="15%" align="right" valign="top" class="summary"> |
| 356 | <span class="summary-type"> </span> |
| 357 | </td><td class="summary"> |
| 358 | <a name="PyCF_ONLY_AST"></a><span class="summary-name">PyCF_ONLY_AST</span> = <code title="1024">1024</code> |
| 359 | </td> |
| 360 | </tr> |
| 361 | <tr> |
| 362 | <td width="15%" align="right" valign="top" class="summary"> |
| 363 | <span class="summary-type"> </span> |
| 364 | </td><td class="summary"> |
| 365 | <a name="__package__"></a><span class="summary-name">__package__</span> = <code title="'TestON.core'"><code class="variable-quote">'</code><code class="variable-string">TestON.core</code><code class="variable-quote">'</code></code> |
| 366 | </td> |
| 367 | </tr> |
| 368 | </table> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 369 | <!-- ==================== FUNCTION DETAILS ==================== --> |
| 370 | <a name="section-FunctionDetails"></a> |
| 371 | <table class="details" border="1" cellpadding="3" |
| 372 | cellspacing="0" width="100%" bgcolor="white"> |
| 373 | <tr bgcolor="#70b0f0" class="table-header"> |
| 374 | <td colspan="2" class="table-header"> |
| 375 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 376 | <tr valign="top"> |
| 377 | <td align="left"><span class="table-header">Function Details</span></td> |
| 378 | <td align="right" valign="top" |
| 379 | ><span class="options">[<a href="#section-FunctionDetails" |
| 380 | class="privatelink" onclick="toggle_private();" |
| 381 | >hide private</a>]</span></td> |
| 382 | </tr> |
| 383 | </table> |
| 384 | </td> |
| 385 | </tr> |
| 386 | </table> |
| 387 | <a name="parse"></a> |
| 388 | <div> |
| 389 | <table class="details" border="1" cellpadding="3" |
| 390 | cellspacing="0" width="100%" bgcolor="white"> |
| 391 | <tr><td> |
| 392 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 393 | <tr valign="top"><td> |
| 394 | <h3 class="epydoc"><span class="sig"><span class="sig-name">parse</span>(<span class="sig-arg">source</span>, |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 395 | <span class="sig-arg">filename</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string"><unknown></code><code class="variable-quote">'</code></span>, |
| 396 | <span class="sig-arg">mode</span>=<span class="sig-default"><code class="variable-quote">'</code><code class="variable-string">exec</code><code class="variable-quote">'</code></span>)</span> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 397 | </h3> |
| 398 | </td><td align="right" valign="top" |
| 399 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#parse">source code</a></span> |
| 400 | </td> |
| 401 | </tr></table> |
| 402 | |
| 403 | <p>Parse the source into an AST node. Equivalent to compile(source, |
| 404 | filename, mode, PyCF_ONLY_AST).</p> |
| 405 | <dl class="fields"> |
| 406 | </dl> |
| 407 | </td></tr></table> |
| 408 | </div> |
| 409 | <a name="literal_eval"></a> |
| 410 | <div> |
| 411 | <table class="details" border="1" cellpadding="3" |
| 412 | cellspacing="0" width="100%" bgcolor="white"> |
| 413 | <tr><td> |
| 414 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 415 | <tr valign="top"><td> |
| 416 | <h3 class="epydoc"><span class="sig"><span class="sig-name">literal_eval</span>(<span class="sig-arg">node_or_string</span>)</span> |
| 417 | </h3> |
| 418 | </td><td align="right" valign="top" |
| 419 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#literal_eval">source code</a></span> |
| 420 | </td> |
| 421 | </tr></table> |
| 422 | |
| 423 | <p>Safely evaluate an expression node or a string containing a Python |
| 424 | expression. The string or node provided may only consist of the |
| 425 | following Python literal structures: strings, numbers, tuples, lists, |
| 426 | dicts, booleans, and None.</p> |
| 427 | <dl class="fields"> |
| 428 | </dl> |
| 429 | </td></tr></table> |
| 430 | </div> |
| 431 | <a name="dump"></a> |
| 432 | <div> |
| 433 | <table class="details" border="1" cellpadding="3" |
| 434 | cellspacing="0" width="100%" bgcolor="white"> |
| 435 | <tr><td> |
| 436 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 437 | <tr valign="top"><td> |
| 438 | <h3 class="epydoc"><span class="sig"><span class="sig-name">dump</span>(<span class="sig-arg">node</span>, |
| 439 | <span class="sig-arg">annotate_fields</span>=<span class="sig-default">True</span>, |
| 440 | <span class="sig-arg">include_attributes</span>=<span class="sig-default">False</span>)</span> |
| 441 | </h3> |
| 442 | </td><td align="right" valign="top" |
| 443 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#dump">source code</a></span> |
| 444 | </td> |
| 445 | </tr></table> |
| 446 | |
| 447 | <p>Return a formatted dump of the tree in *node*. This is mainly useful |
| 448 | for debugging purposes. The returned string will show the names and the |
| 449 | values for fields. This makes the code impossible to evaluate, so if |
| 450 | evaluation is wanted *annotate_fields* must be set to False. Attributes |
| 451 | such as line numbers and column offsets are not dumped by default. If |
| 452 | this is wanted, *include_attributes* can be set to True.</p> |
| 453 | <dl class="fields"> |
| 454 | </dl> |
| 455 | </td></tr></table> |
| 456 | </div> |
| 457 | <a name="fix_missing_locations"></a> |
| 458 | <div> |
| 459 | <table class="details" border="1" cellpadding="3" |
| 460 | cellspacing="0" width="100%" bgcolor="white"> |
| 461 | <tr><td> |
| 462 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 463 | <tr valign="top"><td> |
| 464 | <h3 class="epydoc"><span class="sig"><span class="sig-name">fix_missing_locations</span>(<span class="sig-arg">node</span>)</span> |
| 465 | </h3> |
| 466 | </td><td align="right" valign="top" |
| 467 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#fix_missing_locations">source code</a></span> |
| 468 | </td> |
| 469 | </tr></table> |
| 470 | |
| 471 | <p>When you compile a node tree with compile(), the compiler expects |
| 472 | lineno and col_offset attributes for every node that supports them. This |
| 473 | is rather tedious to fill in for generated nodes, so this helper adds |
| 474 | these attributes recursively where not already set, by setting them to |
| 475 | the values of the parent node. It works recursively starting at |
| 476 | *node*.</p> |
| 477 | <dl class="fields"> |
| 478 | </dl> |
| 479 | </td></tr></table> |
| 480 | </div> |
| 481 | <a name="increment_lineno"></a> |
| 482 | <div> |
| 483 | <table class="details" border="1" cellpadding="3" |
| 484 | cellspacing="0" width="100%" bgcolor="white"> |
| 485 | <tr><td> |
| 486 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 487 | <tr valign="top"><td> |
| 488 | <h3 class="epydoc"><span class="sig"><span class="sig-name">increment_lineno</span>(<span class="sig-arg">node</span>, |
| 489 | <span class="sig-arg">n</span>=<span class="sig-default">1</span>)</span> |
| 490 | </h3> |
| 491 | </td><td align="right" valign="top" |
| 492 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#increment_lineno">source code</a></span> |
| 493 | </td> |
| 494 | </tr></table> |
| 495 | |
| 496 | <p>Increment the line number of each node in the tree starting at *node* |
| 497 | by *n*. This is useful to "move code" to a different location |
| 498 | in a file.</p> |
| 499 | <dl class="fields"> |
| 500 | </dl> |
| 501 | </td></tr></table> |
| 502 | </div> |
| 503 | <a name="get_docstring"></a> |
| 504 | <div> |
| 505 | <table class="details" border="1" cellpadding="3" |
| 506 | cellspacing="0" width="100%" bgcolor="white"> |
| 507 | <tr><td> |
| 508 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 509 | <tr valign="top"><td> |
| 510 | <h3 class="epydoc"><span class="sig"><span class="sig-name">get_docstring</span>(<span class="sig-arg">node</span>, |
| 511 | <span class="sig-arg">clean</span>=<span class="sig-default">True</span>)</span> |
| 512 | </h3> |
| 513 | </td><td align="right" valign="top" |
| 514 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#get_docstring">source code</a></span> |
| 515 | </td> |
| 516 | </tr></table> |
| 517 | |
| 518 | <p>Return the docstring for the given node or None if no docstring can be |
| 519 | found. If the node provided does not have docstrings a TypeError will be |
| 520 | raised.</p> |
| 521 | <dl class="fields"> |
| 522 | </dl> |
| 523 | </td></tr></table> |
| 524 | </div> |
| 525 | <a name="walk"></a> |
| 526 | <div> |
| 527 | <table class="details" border="1" cellpadding="3" |
| 528 | cellspacing="0" width="100%" bgcolor="white"> |
| 529 | <tr><td> |
| 530 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 531 | <tr valign="top"><td> |
| 532 | <h3 class="epydoc"><span class="sig"><span class="sig-name">walk</span>(<span class="sig-arg">node</span>)</span> |
| 533 | </h3> |
| 534 | </td><td align="right" valign="top" |
| 535 | ><span class="codelink"><a href="TestON.core.ast-pysrc.html#walk">source code</a></span> |
| 536 | </td> |
| 537 | </tr></table> |
| 538 | |
| 539 | <p>Recursively yield all descendant nodes in the tree starting at *node* |
| 540 | (including *node* itself), in no specified order. This is useful if you |
| 541 | only want to modify nodes in place and don't care about the context.</p> |
| 542 | <dl class="fields"> |
| 543 | </dl> |
| 544 | </td></tr></table> |
| 545 | </div> |
| 546 | <br /> |
| 547 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 548 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 549 | bgcolor="#a0c0ff" cellspacing="0"> |
| 550 | <tr valign="middle"> |
| 551 | <!-- Home link --> |
| 552 | <th> <a |
| 553 | href="TestON-module.html">Home</a> </th> |
| 554 | |
| 555 | <!-- Tree link --> |
| 556 | <th> <a |
| 557 | href="module-tree.html">Trees</a> </th> |
| 558 | |
| 559 | <!-- Index link --> |
| 560 | <th> <a |
| 561 | href="identifier-index.html">Indices</a> </th> |
| 562 | |
| 563 | <!-- Help link --> |
| 564 | <th> <a |
| 565 | href="help.html">Help</a> </th> |
| 566 | |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 567 | <!-- Project homepage --> |
| 568 | <th class="navbar" align="right" width="100%"> |
| 569 | <table border="0" cellpadding="0" cellspacing="0"> |
| 570 | <tr><th class="navbar" align="center" |
| 571 | >TestON</th> |
| 572 | </tr></table></th> |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 573 | </tr> |
| 574 | </table> |
| 575 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 576 | <tr> |
| 577 | <td align="left" class="footer"> |
Jon Hall | a1cdd89 | 2015-08-10 13:36:28 -0700 | [diff] [blame] | 578 | Generated by Epydoc 3.0.1 on Mon Aug 10 11:12:34 2015 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 579 | </td> |
| 580 | <td align="right" class="footer"> |
| 581 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 582 | >http://epydoc.sourceforge.net</a> |
| 583 | </td> |
| 584 | </tr> |
| 585 | </table> |
| 586 | |
| 587 | <script type="text/javascript"> |
| 588 | <!-- |
| 589 | // Private objects are initially displayed (because if |
| 590 | // javascript is turned off then we want them to be |
| 591 | // visible); but by default, we want to hide them. So hide |
| 592 | // them unless we have a cookie that says to show them. |
| 593 | checkCookie(); |
| 594 | // --> |
| 595 | </script> |
| 596 | </body> |
| 597 | </html> |