Python how to match files to templates
<p>I'm looking to match many files against some common templates, and extract the differences. I'd like suggestions on the best way to do this. For example:</p>

<p>Template A:</p>

<pre><code>&lt;1000 text lines that have to match&gt;
a=?
b=2
c=3
d=?
e=5
f=6
&lt;more text&gt;
</code></pre>

<p>Template B:</p>

<pre><code>&lt;1000 different text lines that have to match&gt;
h=20
i=21
j=?
&lt;more text&gt;
k=22
l=?
m=24
&lt;more text&gt;
</code></pre>

<p>If I passed in file C:</p>

<pre><code>&lt;1000 text lines that match A&gt;
a=500
b=2
c=3
d=600
e=5
f=6
&lt;more text&gt;
</code></pre>

<p>I'd like an easy way to say this matches template A, and extract 'a=500', 'd=600'.</p>

<p>I could match these with a regex, but the files are rather large, and building that regex would be a pain.</p>

<p>I've also tried difflib, but parsing the opcodes and extracting the differences doesn't seem optimal.</p>

<p>Anyone have a better suggestion?</p>
