Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > d4db7b5092b5090e91377eb3dd3b8023 > files > 1682

flumotion-0.6.1-2.fc14.x86_64.rpm

<?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>flumotion.common.fxml.Parser</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">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;flumotion ::
        <a href="flumotion.common-module.html">Package&nbsp;common</a> ::
        <a href="flumotion.common.fxml-module.html">Module&nbsp;fxml</a> ::
        Class&nbsp;Parser
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class Parser</h1><p class="nomargin-top"><span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser">source&nbsp;code</a></span></p>
<pre class="base-tree">
<a href="flumotion.extern.log.log.Loggable-class.html">extern.log.log.Loggable</a> --+
                          |
                         <strong class="uidshort">Parser</strong>
</pre>

<dl><dt>Known Subclasses:</dt>
<dd>
      <ul class="subclass-list">
<li><a href="flumotion.common.config.BaseConfigParser-class.html">config.BaseConfigParser</a></li><li>, <a href="flumotion.admin.rrdmon.config.ConfigParser-class.html">admin.rrdmon.config.ConfigParser</a></li><li class="private">, <a href="flumotion.common.registry.RegistryParser-class.html" onclick="show_private();">registry.RegistryParser</a></li>  </ul>
</dd></dl>

<hr />
<p>XML parser base class.</p>
  <p>I add some helper functions for specialized XML parsers, mostly the 
  parseFromTable method.</p>
  <p>I am here so that the config parser and the registry parser can share 
  code.</p>

<!-- ==================== NESTED CLASSES ==================== -->
<a name="section-NestedClasses"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Nested Classes</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-NestedClasses"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="flumotion.common.fxml.ParserError-class.html" class="summary-name">parserError</a><br />
      Error during parsing of XML.
    </td>
  </tr>
</table>
<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="flumotion.common.fxml.Parser-class.html#getRoot" class="summary-sig-name">getRoot</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">file</span>)</span><br />
      Return the root of the XML tree for the the string or filename passed
      as an argument.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.getRoot">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="flumotion.common.fxml.Parser-class.html#checkAttributes" class="summary-sig-name">checkAttributes</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">node</span>,
        <span class="summary-sig-arg">required</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">optional</span>=<span class="summary-sig-default">None</span>)</span><br />
      Checks that a given XML node has all of the required attributes, and 
      no unknown attributes.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.checkAttributes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">tuple of string or None, as long as the combined length of the 
      required and optional attributes.</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="flumotion.common.fxml.Parser-class.html#parseAttributes" class="summary-sig-name">parseAttributes</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">node</span>,
        <span class="summary-sig-arg">required</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">optional</span>=<span class="summary-sig-default">None</span>,
        <span class="summary-sig-arg">type</span>=<span class="summary-sig-default">&lt;type 'str'&gt;</span>)</span><br />
      Checks the validity of the attributes on an XML node, via 
      Parser.checkAttributes, then parses them out and returns them all as 
      a tuple.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.parseAttributes">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="flumotion.common.fxml.Parser-class.html#parseFromTable" class="summary-sig-name">parseFromTable</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">parent</span>,
        <span class="summary-sig-arg">parsers</span>)</span><br />
      A data-driven verifying XML parser.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.parseFromTable">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="flumotion.common.fxml.Parser-class.html#parseTextNode" class="summary-sig-name">parseTextNode</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">node</span>,
        <span class="summary-sig-arg">type</span>=<span class="summary-sig-default">&lt;type 'str'&gt;</span>)</span><br />
      Parse a text-containing XML node.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.parseTextNode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="flumotion.extern.log.log.Loggable-class.html">extern.log.log.Loggable</a></code></b>:
      <code><a href="flumotion.extern.log.log.Loggable-class.html#__providedBy__">__providedBy__</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#__provides__">__provides__</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#debug">debug</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#doLog">doLog</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#error">error</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#info">info</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#log">log</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#logFunction">logFunction</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#logObjectName">logObjectName</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#warning">warning</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#warningFailure">warningFailure</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#writeMarker">writeMarker</a></code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== CLASS VARIABLES ==================== -->
<a name="section-ClassVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="flumotion.extern.log.log.Loggable-class.html">extern.log.log.Loggable</a></code></b>:
      <code><a href="flumotion.extern.log.log.Loggable-class.html#__implemented__">__implemented__</a></code>,
      <code><a href="flumotion.extern.log.log.Loggable-class.html#logCategory">logCategory</a></code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="getRoot"></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">getRoot</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">file</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.getRoot">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Return the root of the XML tree for the the string or filename passed 
  as an argument. Raises fxml.ParserError if the XML could not be 
  parsed.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>file</code></strong> (File object; can be a duck file like StringIO. Alternately, the 
          path of a file on disk.) - An open file object, or the name of a file. Note that if you pass
          a file object, this function will leave the file open.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="checkAttributes"></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">checkAttributes</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">node</span>,
        <span class="sig-arg">required</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">optional</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.checkAttributes">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Checks that a given XML node has all of the required attributes, and 
  no unknown attributes. Raises fxml.ParserError if unknown or missing 
  attributes are detected. An empty attribute (e.g. 'foo=&quot;&quot;') is 
  treated as a missing attribute.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>node</code></strong> (<a href="flumotion.common.dag.Node-class.html" 
          class="link">xml.dom.Node</a>) - An XML DOM node.</li>
        <li><strong class="pname"><code>required</code></strong> (Sequence (list, tuple, ...) of strings.) - Set of required attributes, or None.</li>
        <li><strong class="pname"><code>optional</code></strong> (Sequence (list, tuple, ...) of strings.) - Set of optional attributes, or None.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="parseAttributes"></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">parseAttributes</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">node</span>,
        <span class="sig-arg">required</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">optional</span>=<span class="sig-default">None</span>,
        <span class="sig-arg">type</span>=<span class="sig-default">&lt;type 'str'&gt;</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.parseAttributes">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Checks the validity of the attributes on an XML node, via 
  Parser.checkAttributes, then parses them out and returns them all as a 
  tuple.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>node</code></strong> (<a href="flumotion.common.dag.Node-class.html" 
          class="link">xml.dom.Node</a>) - An XML DOM node.</li>
        <li><strong class="pname"><code>required</code></strong> (Sequence (list, tuple, ...) of strings.) - Set of required attributes, or None.</li>
        <li><strong class="pname"><code>optional</code></strong> (Sequence (list, tuple, ...) of strings.) - Set of optional attributes, or None.</li>
        <li><strong class="pname"><code>type</code></strong> (Function of type object -&gt; object.) - Type to which to cast attribute values. The original values will 
          always be unicode objects; in most cases you want `str' objects, 
          so this defaults to `str'.</li>
    </ul></dd>
    <dt>Returns: tuple of string or None, as long as the combined length of the 
      required and optional attributes.</dt>
        <dd>List of all attributes as a tuple. The first element of the 
          returned tuple will be the value of the first required attribute,
          the second the value of the second required attribute, and so on.
          The optional attributes follow, with None as the value if the 
          optional attribute was not present.</dd>
  </dl>
</td></tr></table>
</div>
<a name="parseFromTable"></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">parseFromTable</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">parent</span>,
        <span class="sig-arg">parsers</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.parseFromTable">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>A data-driven verifying XML parser. Raises fxml.ParserError if an 
  unexpected child node is encountered.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>parent</code></strong> (<a href="flumotion.common.dag.Node-class.html" 
          class="link">xml.dom.Node</a>) - An XML node whose child nodes you are interested in parsing.</li>
        <li><strong class="pname"><code>parsers</code></strong> (dict of string -&gt; (function, function)) - A parse table defining how to parse the child nodes. The keys are
          the possible child nodes, and the value is a two-tuple of how to 
          parse them consisting of a parser and a value handler. The parser
          is a one-argument function that will be called with the child 
          node as an argument, and the handler is a one-argument function 
          that will be called with the result of calling the parser.</li>
    </ul></dd>
  </dl>
</td></tr></table>
</div>
<a name="parseTextNode"></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">parseTextNode</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">node</span>,
        <span class="sig-arg">type</span>=<span class="sig-default">&lt;type 'str'&gt;</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="flumotion.common.fxml-pysrc.html#Parser.parseTextNode">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Parse a text-containing XML node.</p>
  <p>The node is expected to contain only text children. Recognized node 
  types are <code class="link">xml.dom.Node.TEXT_NODE</code> and <code 
  class="link">xml.dom.Node.CDATA_SECTION_NODE</code>.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>node</code></strong> (<a href="flumotion.common.dag.Node-class.html" 
          class="link">xml.dom.Node</a>) - the node to parse</li>
        <li><strong class="pname"><code>type</code></strong> (function of type unicode -&gt; object) - a function to call on the resulting text</li>
    </ul></dd>
    <dt>Returns:</dt>
        <dd>The result of calling type on the unicode text. By default, type 
          is <code class="link">str</code>.</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">

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

      <th class="navbar" width="100%"></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 Wed Aug 11 21:33:13 2010
    </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>