/usr/share/doc/python-pysmi-doc/html/library-reference.html is in python-pysmi-doc 0.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!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>PySMI library — SNMP SMI compiler 0.1 documentation</title>
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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="shortcut icon" href="_static/favicon.ico"/>
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="MIB compiler" href="pysmi/compiler/mibcompiler.html" />
<link rel="prev" title="The mibdump tool" href="mibdump.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head>
<body>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo">
<a href="contents.html">
<img class="logo" src="_static/logo.svg" alt="Logo"/>
</a>
</p>
<p class="blurb"><p align=left><i><b>Brewing free software for the greater good</i></b></p></p>
<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="documentation.html">PySMI documentation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="mibdump.html">The <em>mibdump</em> tool</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">PySMI library</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="download.html">Download & Install</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="contents.html">Documentation overview</a><ul>
<li><a href="documentation.html">PySMI documentation</a><ul>
<li>Previous: <a href="mibdump.html" title="previous chapter">The <em>mibdump</em> tool</a></li>
<li>Next: <a href="pysmi/compiler/mibcompiler.html" title="next chapter">MIB compiler</a></li>
</ul></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="pysmi-library">
<h1>PySMI library<a class="headerlink" href="#pysmi-library" title="Permalink to this headline">¶</a></h1>
<p>The <em>MibCompiler</em> object is the top-most interface to PySMI library features.
It holds together the otherwise isolated pieces of the compiler infrastructure
and manages the workflow of ASN.1 MIB transformation.</p>
<p>This example showcases some of its features:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pysmi.reader</span> <span class="kn">import</span> <span class="n">HttpReader</span>
<span class="kn">from</span> <span class="nn">pysmi.searcher</span> <span class="kn">import</span> <span class="n">StubSearcher</span>
<span class="kn">from</span> <span class="nn">pysmi.writer</span> <span class="kn">import</span> <span class="n">CallbackWriter</span>
<span class="kn">from</span> <span class="nn">pysmi.parser</span> <span class="kn">import</span> <span class="n">SmiStarParser</span>
<span class="kn">from</span> <span class="nn">pysmi.codegen</span> <span class="kn">import</span> <span class="n">JsonCodeGen</span>
<span class="kn">from</span> <span class="nn">pysmi.compiler</span> <span class="kn">import</span> <span class="n">MibCompiler</span>
<span class="n">inputMibs</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'IF-MIB'</span><span class="p">,</span> <span class="s1">'IP-MIB'</span><span class="p">]</span>
<span class="n">httpSources</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">'mibs.snmplabs.com'</span><span class="p">,</span> <span class="mi">80</span><span class="p">,</span> <span class="s1">'/asn1/@mib@'</span><span class="p">)]</span>
<span class="c1"># store compiled MIBs by calling this function</span>
<span class="k">def</span> <span class="nf">store_mibs</span><span class="p">(</span><span class="n">mibName</span><span class="p">,</span> <span class="n">jsonDoc</span><span class="p">,</span> <span class="n">cbCtx</span><span class="p">):</span>
<span class="k">print</span><span class="p">(</span><span class="s1">'# MIB module </span><span class="si">%s</span><span class="s1">'</span> <span class="o">%</span> <span class="n">mibName</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">jsonDoc</span><span class="p">)</span>
<span class="n">mibCompiler</span> <span class="o">=</span> <span class="n">MibCompiler</span><span class="p">(</span>
<span class="n">SmiStarParser</span><span class="p">(),</span> <span class="n">JsonCodeGen</span><span class="p">(),</span> <span class="n">CallbackWriter</span><span class="p">(</span><span class="n">store_mibs</span><span class="p">)</span>
<span class="p">)</span>
<span class="c1"># pull ASN.1 MIBs over HTTP</span>
<span class="n">mibCompiler</span><span class="o">.</span><span class="n">addSources</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="n">HttpReader</span><span class="p">(</span><span class="o">*</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">httpSources</span><span class="p">])</span>
<span class="c1"># never recompile MIBs with ASN.1 MACROs</span>
<span class="n">mibCompiler</span><span class="o">.</span><span class="n">addSearchers</span><span class="p">(</span><span class="n">StubSearcher</span><span class="p">(</span><span class="o">*</span><span class="n">JsonCodeGen</span><span class="o">.</span><span class="n">baseMibs</span><span class="p">))</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">mibCompiler</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="o">*</span><span class="n">inputMibs</span><span class="p">)</span>
<span class="k">print</span><span class="p">(</span><span class="n">status</span><span class="p">)</span>
</pre></div>
</div>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/compiler/mibcompiler.html">MIB compiler</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/compiler/mibstatus.html">Compilation status</a></li>
</ul>
</div>
<div class="section" id="mib-sources">
<h2>MIB sources<a class="headerlink" href="#mib-sources" title="Permalink to this headline">¶</a></h2>
<p>PySMI offers a handful of distinct transport mechanisms for fetching MIBs by
name from specific locations. In all cases MIB module name to file name match
may not be exact – some name fuzzying can be performed to mitigate
possible changes to MIB file name.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/reader/localfile/filereader.html">Local file reader</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/reader/zipreader/zipreader.html">ZIP archive reader</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/reader/httpclient/httpreader.html">HTTP reader</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/reader/ftpclient/ftpreader.html">FTP reader</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/reader/callback/callbackreader.html">Callback reader</a></li>
</ul>
</div>
</div>
<div class="section" id="conditional-compilation">
<h2>Conditional compilation<a class="headerlink" href="#conditional-compilation" title="Permalink to this headline">¶</a></h2>
<p>There are cases when MIB transformation may or must not be performed.
Such cases include:</p>
<ul class="simple">
<li>foundation MIBs containing manually implemented pieces or ASN.1 MACRO’s</li>
<li>obsolete MIBs fully reimplemented within modern MIBs</li>
<li>already transformed MIBs</li>
</ul>
<p><a class="reference internal" href="pysmi/compiler/mibcompiler.html#compiler-mibcompiler"><span class="std std-ref">MibCompiler</span></a> expects user to supply a
<em>searcher</em> object that would allow or skip MIB transformation for particular
name based on whatever reason it is aware of.</p>
<p>In general, <em>searcher</em> logic is specific to target format. At the time being,
only <a class="reference external" href="http://snmplabs.com/pysnmp">pysnmp</a> code generation backend requires
such filtering.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/searcher/pyfile/pyfilesearcher.html">Python files searcher</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/searcher/pypackage/pypackagesearcher.html">Search Python packages</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/searcher/stub/stubsearcher.html">Unconditionally ignore MIBs</a></li>
</ul>
</div>
</div>
<div class="section" id="parser-configuration">
<h2>Parser configuration<a class="headerlink" href="#parser-configuration" title="Permalink to this headline">¶</a></h2>
<p>MIBs may be written in one of the two major SMI language versions (v1 and v2).
Some MIBs may contain typical errors.</p>
<p>PySMI offers a way to customize the parser to consume either of the major SMI
grammars as well as to recover from well-known errors in MIB files.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/parser/smi/parserfactory.html">SMI parser</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/parser/smi/dialect.html">SMI language dialects</a></li>
</ul>
</div>
</div>
<div class="section" id="code-generators">
<h2>Code generators<a class="headerlink" href="#code-generators" title="Permalink to this headline">¶</a></h2>
<p>Once ASN.1 MIB is parsed up, AST is passed to a code generator which turns
AST into desired representation of the MIB.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/codegen/jsondoc/jsoncodegen.html">JSON document generator</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/codegen/pysnmp/pysnmpcodegen.html">PySNMP MIB generator</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/codegen/null/nullcodegen.html">Code generation stub</a></li>
</ul>
</div>
</div>
<div class="section" id="borrow-pre-compiled-mibs">
<h2>Borrow pre-compiled MIBs<a class="headerlink" href="#borrow-pre-compiled-mibs" title="Permalink to this headline">¶</a></h2>
<p>Some MIBs in circulation appear broken beyond automatic repair. To
handle such cases PySMI introduces the <em>MIB borrowing</em>
functionality. When <a class="reference internal" href="pysmi/compiler/mibcompiler.html#compiler-mibcompiler"><span class="std std-ref">MibCompiler</span></a>
gives up compiling a MIB, it can try to go out and take a copy of
already transformed MIB to complete the request successfully.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/borrower/anyfile/anyfileborrower.html">Any file borrower</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/borrower/pyfile/pyfileborrower.html">Python file borrower</a></li>
</ul>
</div>
</div>
<div class="section" id="write-compiled-mibs">
<h2>Write compiled MIBs<a class="headerlink" href="#write-compiled-mibs" title="Permalink to this headline">¶</a></h2>
<p>Successfully transformed MIB modules’ contents will be passed to <em>writer</em>
object given to <a class="reference internal" href="pysmi/compiler/mibcompiler.html#compiler-mibcompiler"><span class="std std-ref">MibCompiler</span></a> on instantiation.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="pysmi/writer/localfile/filewriter.html">File writer</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/writer/pyfile/pyfilewriter.html">Python file writer</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysmi/writer/callback/callbackwriter.html">Callback writer</a></li>
</ul>
</div>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<p>The following examples focus on various feature of the PySMI library.</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="examples/download-and-compile-smistar-mibs-into-json.html">Compile MIBs into JSON</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/download-and-compile-smistar-mibs-into-pysnmp-files.html">Compile MIBs from web</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/compile-smistar-mibs-into-pysnmp-files-if-needed.html">Compile SMIv1/v2 MIBs</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/compile-smiv2-mibs-from-text-into-pysnmp-code.html">Compile SMIv2 MIBs</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/borrow-precompiled-pysnmp-files-on-failure.html">Borrow pysnmp MIBs on failure</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples/always-borrow-precompiled-pysnmp-files.html">Always borrow pysnmp MIBs</a></li>
</ul>
</div>
<p>In case of any troubles or confusion, try enabling PySMI debugging
and watch the output:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pysmi</span> <span class="kn">import</span> <span class="n">debug</span>
<span class="n">debug</span><span class="o">.</span><span class="n">setLogger</span><span class="p">(</span><span class="n">debug</span><span class="o">.</span><span class="n">Debug</span><span class="p">(</span><span class="s1">'all'</span><span class="p">))</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2015-2017, Ilya Etingof <etingof@gmail.com>.
</div>
</body>
</html>
|