In Python find and extract only required info
<p>I am getting info from an HP device and storing it in a variable named <code>data</code>.</p>

<p>Now, I want to extract only the values for <code>Chassis:</code> and <code>Serial Number:</code> from the output, an example of which is below (I obtain it by typing the command <code>show module</code>):</p>

<pre><code>============================
coaza077-cor-01&gt; show module

 Status and Counters - Module Information
  Chassis: 2900-24G J9049A         Serial Number:   SG748KI09F
  Slot  Module Description                       Serial Number
  ----- ---------------------------------------- --------------

coaza077-cor-01&gt; exit
Do you want to log out [y/n]? y
=============================
</code></pre>

<p>The code below is my attempt to do this:</p>

<pre><code>    sList = os.linesep.join([s for s in data.splitlines() if s])


for i in range(0,len(sList)):

    if (sList[i].lower()).find('Chassis') &gt;= 0:
        #DEVICE PROCESSOR
        device_processor= _parse.getdata(sList[i].lower(), 'Chassis:', ' ')
        if debugging == "_HP2900" or debugging == "ALL": print "_HP2900.py", "Processor", device_processor          

    if (sList[i].lower()).find('Serial Number') &gt;= 0:
        print 'Serial Number'
        #DEVICE SERIAL NUMBER
        device_serial= (_parse.serial_number(sList[i].lower()[len('Serial Number'):])).upper()
        if debugging == "_HP2900" or debugging == "ALL": print "_HP2900.py", "Serial", device_serial
</code></pre>

<p>.. however I can't seem to get only the two values that I need. I'm new to Python, and not sure that I'm even approaching the problem correctly.</p>

<p>How can I get just the fields that I need? </p>
