pylspci/index.html

206 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>Python lspci parser &#8212; pylspci 0.4.3 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Command-line interface" href="cli.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">
<h1 class="logo"><a href="#">pylspci</a></h1>
<p class="blurb">Python lspci parser</p>
<h3>Navigation</h3>
<ul>
<li class="toctree-l1"><a class="reference internal" href="cli.html">Command-line interface</a></li>
<li class="toctree-l1"><a class="reference internal" href="data.html">Parsed data</a></li>
<li class="toctree-l1"><a class="reference internal" href="command.html">Command API</a></li>
<li class="toctree-l1"><a class="reference internal" href="low.html">Low-level classes</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
</ul>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="#">Documentation overview</a><ul>
<li>Next: <a href="cli.html" title="next chapter">Command-line interface</a></li>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="python-lspci-parser">
<h1>Python lspci parser<a class="headerlink" href="#python-lspci-parser" title="Permalink to this heading"></a></h1>
<p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a> - <a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a> - <a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p>
<a class="reference external image-reference" href="https://pypi.org/project/pylspci"><img alt="https://img.shields.io/pypi/v/pylspci.svg" src="https://img.shields.io/pypi/v/pylspci.svg" /></a>
<a class="reference external image-reference" href="https://pypi.org/project/pylspci"><img alt="https://img.shields.io/pypi/l/pylspci.svg" src="https://img.shields.io/pypi/l/pylspci.svg" /></a>
<a class="reference external image-reference" href="https://pypi.org/project/pylspci"><img alt="https://img.shields.io/pypi/format/pylspci.svg" src="https://img.shields.io/pypi/format/pylspci.svg" /></a>
<a class="reference external image-reference" href="https://pypi.org/project/pylspci"><img alt="https://img.shields.io/pypi/pyversions/pylspci.svg" src="https://img.shields.io/pypi/pyversions/pylspci.svg" /></a>
<a class="reference external image-reference" href="https://pypi.org/project/pylspci"><img alt="https://img.shields.io/pypi/status/pylspci.svg" src="https://img.shields.io/pypi/status/pylspci.svg" /></a>
<a class="reference external image-reference" href="https://drone.tildegit.org/api/badges/lucidiot/pylspci/status.svg"><img alt="https://drone.tildegit.org/api/badges/lucidiot/pylspci/status.svg" src="https://drone.tildegit.org/api/badges/lucidiot/pylspci/status.svg" /></a>
<a class="reference external image-reference" href="https://tildegit.org/lucidiot/pylspci"><img alt="https://img.shields.io/badge/badge%20count-7-brightgreen.svg" src="https://img.shields.io/badge/badge%20count-7-brightgreen.svg" /></a>
<p>A Python parser for the <code class="docutils literal notranslate"><span class="pre">lspci</span></code> command from the <a class="reference external" href="http://mj.ucw.cz/sw/pciutils/">pciutils</a> package.</p>
<section id="command-line-interface">
<h2>Command-line interface<a class="headerlink" href="#command-line-interface" title="Permalink to this heading"></a></h2>
<p>An executable script named <code class="docutils literal notranslate"><span class="pre">pylspci</span></code> is available, and acts as a wrapper
around <code class="docutils literal notranslate"><span class="pre">lspci</span></code> that can produce JSON output.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ pylspci -nn
[{
&quot;slot&quot;: {&quot;domain&quot;: 0, &quot;bus&quot;: 0, &quot;device&quot;: 1, &quot;function&quot;: 3},
&quot;device&quot;: {&quot;id&quot;: 9248, &quot;name&quot;: &quot;Name A&quot;},
...
}]
</pre></div>
</div>
<p>See <code class="docutils literal notranslate"><span class="pre">pylspci</span> <span class="pre">--help</span></code> and the <a class="reference external" href="cli">CLI docs</a> to learn more.</p>
</section>
<section id="parsing-in-python">
<h2>Parsing in Python<a class="headerlink" href="#parsing-in-python" title="Permalink to this heading"></a></h2>
<p>To parse <code class="docutils literal notranslate"><span class="pre">lspci</span> <span class="pre">-nnmm</span></code>, use the
<a class="reference internal" href="low.html#pylspci.parsers.simple.SimpleParser" title="pylspci.parsers.simple.SimpleParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleParser</span></code></a>.
To parse <code class="docutils literal notranslate"><span class="pre">lspci</span> <span class="pre">-nnmmvvvk</span></code>, use the
<a class="reference internal" href="low.html#pylspci.parsers.verbose.VerboseParser" title="pylspci.parsers.verbose.VerboseParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">VerboseParser</span></code></a>.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pylspci.parsers</span> <span class="kn">import</span> <span class="n">SimpleParser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">SimpleParser</span><span class="p">()</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="go">[Device(slot=Slot(&#39;0000:00:01.3&#39;), name=NameWithID(&#39;Name A [2420]&#39;), ...),</span>
<span class="go"> Device(slot=Slot(&#39;0000:00:01.4&#39;), name=NameWithID(&#39;Name B [0e54]&#39;), ...)]</span>
</pre></div>
</div>
<section id="custom-arguments">
<h3>Custom arguments<a class="headerlink" href="#custom-arguments" title="Permalink to this heading"></a></h3>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pylspci.command</span> <span class="kn">import</span> <span class="n">IDResolveOption</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pylspci.parsers</span> <span class="kn">import</span> <span class="n">VerboseParser</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">VerboseParser</span><span class="p">()</span><span class="o">.</span><span class="n">run</span><span class="p">(</span>
<span class="gp">... </span> <span class="n">hide_single_domain</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">id_resolve_option</span><span class="o">=</span><span class="n">IDResolveOption</span><span class="o">.</span><span class="n">NameOnly</span><span class="p">,</span>
<span class="gp">... </span><span class="p">)</span>
<span class="go">[Device(slot=Slot(&#39;0000:00:01.3&#39;), name=NameWithID(&#39;Name A&#39;), ...),</span>
<span class="go"> Device(slot=Slot(&#39;0000:00:01.4&#39;), name=NameWithID(&#39;Name B&#39;), ...)]</span>
</pre></div>
</div>
</section>
</section>
<section id="learn-more">
<h2>Learn more<a class="headerlink" href="#learn-more" title="Permalink to this heading"></a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="cli.html">Command-line interface</a><ul>
<li class="toctree-l2"><a class="reference internal" href="cli.html#options">Options</a><ul>
<li class="toctree-l3"><a class="reference internal" href="cli.html#filters">Filters</a></li>
<li class="toctree-l3"><a class="reference internal" href="cli.html#device-data">Device data</a></li>
<li class="toctree-l3"><a class="reference internal" href="cli.html#output-modes">Output modes</a></li>
<li class="toctree-l3"><a class="reference internal" href="cli.html#pci-access">PCI access</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="data.html">Parsed data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="data.html#module-pylspci.device">The Device</a></li>
<li class="toctree-l2"><a class="reference internal" href="data.html#module-pylspci.fields">Device fields</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="command.html">Command API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="command.html#command-builder">Command builder</a></li>
<li class="toctree-l2"><a class="reference internal" href="command.html#module-pylspci.filters">Device selection</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="low.html">Low-level classes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="low.html#module-pylspci.parsers.base">Parsers</a></li>
<li class="toctree-l2"><a class="reference internal" href="low.html#module-pylspci.parsers.verbose">Implementation details</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#bugs-and-suggestions">Bugs and suggestions</a></li>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#development">Development</a><ul>
<li class="toctree-l3"><a class="reference internal" href="contributing.html#setup">Setup</a></li>
<li class="toctree-l3"><a class="reference internal" href="contributing.html#unit-tests">Unit tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="contributing.html#tests-coverage">Tests coverage</a></li>
<li class="toctree-l3"><a class="reference internal" href="contributing.html#linting">Linting</a></li>
<li class="toctree-l3"><a class="reference internal" href="contributing.html#type-checking">Type checking</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="contributing.html#documentation">Documentation</a></li>
</ul>
</li>
</ul>
</div>
</section>
</section>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
&copy;2022, Lucidiot and contributors.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 5.1.1</a>
&amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/index.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>